开发者

Can't send with cURL in PHP

I created a test host on 0fees.net. I also create a small php script that will receive the file i wish to send.

I tried a lot of things but server responds with HTTP 403 Forbidden; The actual message in verbose output is

* About to connect() to ********* port 80 (#0)
*   Trying 209.190.85.12... * connected
* Connected to ******* (209.190.85.12) port 80 (#0)
> POST /index.php HTTP/1.1
Host: *************
Accept: */*
Content-Length: 791
Expect: 100-continue
Content-Type: multipart/form-data; boundary=----------------------------4cad4df8
02c5

* The requested URL returned error: 403
* Closing connection #0
* HTTP response code said error

The code i use is

curl_easy_setopt(curl, CURLOPT_URL, link);
curl_easy_setopt(curl, CURLOPT_HEADER, "User-Agent: 开发者_如何转开发Mozilla/5.0 (Windows NT 6.1) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.30 Safari/534.30");
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
curl_easy_setopt(curl, CURLOPT_FAILONERROR, true);
curl_easy_setopt (curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt (curl, CURLOPT_POST, 1);
curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "");
curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
curl_easy_perform(curl);

Most of the curlopts stuff i added simply because i get the aforementioned http 403 error. How can i resolve this?

P.S This code works flawlessly on my localhost setup!


403 forbidden usually means that you're sending a request either using the wrong method or to the wrong URL.


@dikidera I think CURL support is not available in 0fees.net

Check with this code

if (function_exists('curl_init')) 
{echo "yes";}
else { echo "No"; }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜