-1

Hey guys i'm trying to make a curl request to facebook Graph API, but when i use $curl_exec it returns nothing.

My code:

 $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, BioCommandController::getGraphUrl(). $this->{self::AD_ACCOUNT_ID}.'/offsitepixels?'.$fields_string);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $return = curl_exec($ch);

curl_getinfo() response:

    Array
    (
    [url] => https://graph.facebook.com/v2.3/ MY DATA
    [content_type] =>
    [http_code] => 0
    [header_size] => 0
    [request_size] => 0
    [filetime] => -1
    [ssl_verify_result] => 1
    [redirect_count] => 0
    [total_time] => 0.031
    [namelookup_time] => 0
    [connect_time] => 0.016
    [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
    [redirect_url] =>
    [primary_ip] => 2a03:2880:f005:1:face:b00c:0:1
    [certinfo] => Array
        (
        )

    [primary_port] => 443
    [local_ip] => 2804:7f5:f180:dc6d:c5e5:3e79:d447:d583
    [local_port] => 54603
)

I'm new to Curl so i have no idea how to interpretate the getinfo response, also i have tested my graph api resuqest on my browser and it works, it returns what i need! And also even if i was generating something weong on my graph API request Facebook always answers something for example:

{ "error": { "message": "An active access token must be used to query information about the current user.", "type": "OAuthException", "code": 2500 } }

Does anyone know whats going on? I can't seem to figure it out, thanks!

UPDATE

id runed this code (So u can really know what's going on wwith curl)

if ($return === false) { die(curl_error($ch)); }

and i got this:

SSL certificate problem: unable to get local issuer certificate

Bacteria
  • 8,406
  • 10
  • 50
  • 67
  • 1
    `if ($result === false) { die(curl_error($ch)); }`. have curl TELL you what went wrong. "blank" doesn't mean it's really empty. boolean falses print as zero-length strings. – Marc B Sep 01 '15 at 18:31
  • Thanks, ive tried that i got this: "SSL certificate problem: unable to get local issuer certificate" i'll try to find out how to fix it – Michelle Colin Sep 01 '15 at 18:35

1 Answers1

-1

Hey guys this is how i solved my problem:

Relating to 'SSL certificate problem: unable to get local issuer certificate' error. Rather obviously this applies to the system sending the CURL request (and no the server receiving the request)

1) Download the latest cacert.pem from http://curl.haxx.se/ca/cacert.pem

2) Add the following line to php.ini (if this is shared hosting and you don't have access to php.ini then you could add this to .user.ini in public_html)

curl.cainfo=/path/to/downloaded/cacert.pem

curl: (60) SSL certificate : unable to get local issuer certificate

Community
  • 1
  • 1