我想在Facebook上获取用户名。为此,我尝试使用FQL查询。代码是,
$result = $facebook->api_client->fql_query("SELECT name FROM user WHERE uid='$user_id');
但这有一些问题。我想查询没有被执行或者它返回空值。我也尝试过使用users.getInfo,如下所示,
$result = $facebook->api_client->users_getInfo($user_id,'name');
但是,同样的问题。
我试图将数组显示为,
echo $result['name];
所以,我尝试了两个代码,
if(!$facebook->api_client->fql_query("SELECT name FROM user WHERE uid='$user_id')) {
echo "Error.";
}
我在php文件中包含了facebook.php和facebookapi_php5_restlib.php。我哪里错了?
答案 0 :(得分:0)
现在我可以修复这个问题.. 打开并修改文件facebookapi_php5_restlib.php并像这样
public function post_request($method, $params, $server_addr) {
list($get, $post) = $this->finalize_params($method, $params);
$post_string = $this->create_url_string($post);
$get_string = $this->create_url_string($get);
$url_with_get = $server_addr . '?' . $get_string;
if ($this->use_curl_if_available && function_exists('curl_init'))
{
$useragent = 'Facebook API PHP5 Client 1.1 (curl) ' . phpversion();
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url_with_get);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3600);
curl_setopt($ch, CURLOPT_TIMEOUT, 3600);
$result = $this->curl_exec($ch);
curl_close($ch);
} else {
$content_type = 'application/x-www-form-urlencoded';
$content = $post_string;
$result = $this->run_http_post_transaction($content_type,$content, $url_with_get);
}
return $result;
}
更改
的时间