0

我想在 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。我哪里错了?

4

1 回答 1

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;
  }

更改超时时间

于 2010-07-29T10:11:20.917 回答