0

Hi everyone, I have been trying to code a facebook application using the API.
Within this, I am required to include the base_facebook.php file.

But I keep gertting an error
Fatal error: Uncaught OAuthException: An active access token must be used to query information about the current user. thrown in base_facebook.php on line 1033

I have been doinf some digging around and a number of websites say there should be additional CURL information sent when hosting with godaddy shared hosting as godaddy use a proxy server.

Here is the code from the websites.

...assuming that $ch is the curl handle.

A full example...


<?php
$url = "http://www.google.com/";

$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
curl_setopt ($ch, CURLOPT_PROXY,"http://64.202.165.130:3128");
curl_setopt ($ch, CURLOPT_TIMEOUT, 120);
$response = curl_exec ($ch);
if(is_int($response)) {
    die("Errors: " . curl_errno($ch) . " : " . curl_error($ch));
}
curl_close ($ch);

print "Remote Site : $url<br /><hr />$response";
?>

Here is the curl configuration in the base_facebook.php

    curl_setopt_array($ch, $opts);
    $result = curl_exec($ch);

    if (curl_errno($ch) == 60) { // CURLE_SSL_CACERT
      self::errorLog('Invalid or no certificate authority found, '.
                     'using bundled information');
      curl_setopt($ch, CURLOPT_CAINFO,
                  dirname(__FILE__) . '/fb_ca_chain_bundle.crt');
      $result = curl_exec($ch);
    }

    if ($result === false) {
      $e = new FacebookApiException(array(
        'error_code' => curl_errno($ch),
        'error' => array(
        'message' => curl_error($ch),
        'type' => 'CurlException',
        ),
      ));
      curl_close($ch);
      throw $e;
    }
    curl_close($ch);
    return $result;
  }

What I dont no is how to add the additional curl configuration to base_facebook.php file

Cheers

2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by veedeoo
0

Hi,

Is this the PHP/SDK you are currently using?

if so, then additional cURL configuration can be added like this

 public static $CURL_OPTS = array(
CURLOPT_CONNECTTIMEOUT => 10,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 60,
## lets add proxy type 
CURLOPT_PROXYTYPE => CURLPROXY_HTTP;
## lets add the proxy ip
CURLOPT_PROXY => 'http://64.202.165.130:3128';
CURLOPT_USERAGENT => 'facebook-php-3.1',

If NOT, look for function curl_setopt_array in your base_facebook.php. You should be able to see how the options were defined. Better yet, just post the code here, and we will try to help you out.

  function curl_setopt_array ($ch, $opts){

  }

Edited by veedeoo: more info added

0

CORRECTIONS!

Do it like this

 ## lets add proxy type
 CURLOPT_PROXYTYPE => CURLPROXY_HTTP,
 ## lets add the proxy ip
 CURLOPT_PROXY => 'http://64.202.165.130:3128',

Use comma intead, because it is an array..... I completely missed it BIG time... :). I think I am just running out of coffee..

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.