Facebook应用程序:获取个人资料(名称)失败


Facebook app: fail to fetch profile information (name)

当我写这段代码时> '

require 'facebook-api/facebook.php';
// Creating our Application instance (replace this with your appId and secret).
$facebook = new Facebook(array(
  'appId'  => '143873775888888',
  'secret' => '650e5a4645f44g5s5f8edh58395a16',
));

$user = $facebook->getUser();
echo $user;
  /*  You application logic goes here  */
$access_token = $facebook->getAccessToken();
echo $access_token;

?>
<h3> Welcome <?php  echo $user_profile['name']; ?> !!! </h3>
<img src="https://graph.facebook.com/<?php echo $user; ?>/picture">`

当我写这段代码时,一切正常!但是当我添加这段代码->$user_profile = $facebook->api('/me','GET');它给出了错误说明Fatal error: Uncaught CurlException: 7: couldn't connect to host thrown in /home/u516971380/public_html/p/php/facebook-api/base_facebook.php on line 1012……我使用的是facebook sdk 3.2.3(不是最新版本4)。请告诉我这段代码有什么问题,这样问题就发生了…

设置代理连接Facebook.com

在base_facebook.php中查找代码

public static $CURL_OPTS = array(
    CURLOPT_CONNECTTIMEOUT => 10,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT        => 60,
    CURLOPT_USERAGENT      => 'facebook-php-3.2',
  );

And Add option

  public static $CURL_OPTS = array(
    CURLOPT_CONNECTTIMEOUT => 10,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT        => 60,
    CURLOPT_USERAGENT      => 'facebook-php-3.2',
    CURLOPT_PROXY      => '199.200.120.140:8089',
  );