0

Having issues using cURL on windows vista. The library is there and showing with phpinfo(), but curl_exec() is not returning the web page content - when uploaded and tested on a linux server there's no problems with the same code, returns the data as expected.

Does anyone have any experience with this/ideas? I'm using xampp and php 5.2.6.

UPDATE:

Array( [url] => https://graph.facebook.com/me
    [content_type] => [http_code] => 0
    [header_size] => 0
    [request_size] => 0
    [filetime] => -1
    [ssl_verify_result] => 0
    [redirect_count] => 0
    [total_time] => 0
    [namelookup_time] => 0
    [connect_time] => 0.203
    [pretransfer_time] => 0
    [size_upload] => 0
    [size_download] => 0
    [speed_download] => 0
    [speed_upload] => 0
    [download_content_length] => -1
    [upload_content_length] => -1
    [starttransfer_time] => 0
    [redirect_time] => 0 )

Is the response I get from print_r(curl_getinfo($ch));

6
  • 1
    It might be a windows firewall issue...can you paste your code here, and the output when run from the command line?
    – AJ.
    Apr 16, 2011 at 18:51
  • I just included an update with what curl is doing. I've disabled windows firewall and it made no difference. Apr 16, 2011 at 18:58
  • Also, running from GIT BASH, curl -L google.com works fine. Apr 16, 2011 at 19:03
  • When I go to graph.facebook.com/me in a browser, I get this JSON response: { "error": { "type": "OAuthException", "message": "An active access token must be used to query information about the current user." } } How are you authenticating your request?
    – AJ.
    Apr 16, 2011 at 19:31
  • AJ - the authentication isn't the problem, I don't get any JSON or anything back. Apr 16, 2011 at 23:43

2 Answers 2

1

I noticed that's a https address.

Try doing this:

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 

Setting that to false allows Curl to accept any CA.

You can check the documentation here:
http://php.net/manual/en/function.curl-setopt.php

CURLOPT_SSL_VERIFYPEER
FALSE to stop cURL from verifying the peer's certificate. Alternate certificates to verify against can be specified with the CURLOPT_CAINFO option or a certificate directory can be specified with the CURLOPT_CAPATH option. CURLOPT_SSL_VERIFYHOST may also need to be TRUE or FALSE if CURLOPT_SSL_VERIFYPEER is disabled (it defaults to 2).

4
  • Wow, thanks that's great. Fixed it! I wonder why they don't include that in the standard facebook php sdk? I guess it has security set backs potentially if the facebook site was attacked. Apr 16, 2011 at 23:46
  • Hmmm... this may have fixed it... but.. I would check to see if they have any documentation on how to handle FB SSL and try to use that. This method basically accepts any CA. Which may or may not be secure depending on what you're doing with it.
    – PiZzL3
    Apr 16, 2011 at 23:51
  • I just googled it to check on things. It seems this is a standard fix for your type of error. You should be ok.
    – PiZzL3
    Apr 16, 2011 at 23:55
  • I also just read that it's not "included" because the error depends on what kind of system you're running on.
    – PiZzL3
    Apr 16, 2011 at 23:56
0

I think you should change: [url] => https://graph.facebook.com/me to

[url] => "https://graph.facebook.com/me"

I assume that you are using commas to separate the key-value pairs in php array.

1
  • It would display like this:array("url" => "https://graph.facebook.com/me");. [url] => https://graph.facebook.com/me is just the printed version using print_r or a similar function. Also, the printed data looks like the CURL_INFO output to me.
    – PiZzL3
    Apr 16, 2011 at 19:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.