Discuss Trouble with a cURL request in PHP in the PHP Development forum on Dev Shed. Trouble with a cURL request in PHP PHP Development forum discussing coding practices, tips on PHP, and other PHP-related topics. PHP is an open source scripting language that has taken the web development industry by storm.
The ASP Free website provides in-depth information on the latest developer tools available from Microsoft. Our cadre of writers, highly experienced industry experts, reveals the best ways to use established technologies as well as new and emerging technologies. Our coverage of Microsoft's development and administration technologies is among the most respected in the IT industry today.
ASP Free and Iron Speed Designer are giving away $5,500+ in FREE licenses. Iron Speed's RAD CASE toolset can save up to 80% of your coding time. One free license per week, one perpetual license per month! Download and Activate to enter!
Intel® Graphics Performance Analyzers is a powerful tool suite for analyzing and optimizing your games, media, and graphics-intensive applications. Used by some of the best developers on the planet, Intel GPA lets you maximize your app’s performance.
Posts: 52
Time spent in forums: 16 h 41 m 55 sec
Reputation Power: 7
Trouble with a cURL request in PHP
Hi,
I'm trying to do a cURL request with curl_init() and having problems with certain URLs that I can get to work fine through the shell. The request is for a URL with a query string that should do a 302 redirect, but when cURL tries to make the request, it first does a request for only the hostname. The problem is that the page on the base hostname, returns a 403.
Posts: 1,586
Time spent in forums: 4 Weeks 1 h 34 m 20 sec
Reputation Power: 273
Just so you know, next time...
Anytime you set the option...
PHP Code:
curl_setopt($ch, CURLOPT_NOBODY, true);
CURLOPT_NOBODY automatically shifts the request to a HEAD, type request, so most servers don't allow HEAD type requests, results most times in 403 errors, so you use...
PHP Code:
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
So cURL, will send the request as GET or POST, but still only really make a HEAD request because the CURLOPT_NOBODY flag was set to true, which causes cURL to read only up to the end of the response header.
Posts: 1
Time spent in forums: 2 m 32 sec
Reputation Power: 0
Quote:
Originally Posted by printf
Just so you know, next time...
Anytime you set the option...
PHP Code:
curl_setopt($ch, CURLOPT_NOBODY, true);
CURLOPT_NOBODY automatically shifts the request to a HEAD, type request, so most servers don't allow HEAD type requests, results most times in 403 errors, so you use...
PHP Code:
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
So cURL, will send the request as GET or POST, but still only really make a HEAD request because the CURLOPT_NOBODY flag was set to true, which causes cURL to read only up to the end of the response header.