当我写这段代码>`时
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">`
当我写这段代码时,一切顺利!但是当我添加此代码时 - &gt; $ user_profile = $ facebook-&gt; api(&#39; / me&#39;,&#39; GET&#39;);它给出了错误的说法
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)。请告诉我这段代码有什么问题,以便发生问题...
答案 0 :(得分:0)
在base_facebook.php中找到代码
public static $CURL_OPTS = array(
CURLOPT_CONNECTTIMEOUT => 10,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 60,
CURLOPT_USERAGENT => 'facebook-php-3.2',
);
添加选项
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',
);