2010-04-08 5 views
0

나는 페이스 북에서 사용자의 이름을 가져오고 싶습니다. 이를 위해 FQL 쿼리를 사용해 보았습니다. 코드는 다음과 같습니다.PHP에서 fql 쿼리 문제가

$result = $facebook->api_client->fql_query("SELECT name FROM user WHERE uid='$user_id'); 

하지만 약간의 문제가 있습니다. 쿼리가 실행되지 않거나 Null 값을 반환하는 것 같습니다. 나는 또한 users.getInfo를 다음과 같이 사용하여 시도했다.

$result = $facebook->api_client->users_getInfo($user_id,'name'); 

다시 같은 문제. 나뿐만 배열을 표시하려고

,

echo $result['name]; 

그래서, 난 내 PHP 파일 모두 facebook.php 및 facebookapi_php5_restlib.php을 포함했다

if(!$facebook->api_client->fql_query("SELECT name FROM user WHERE uid='$user_id')) { 
    echo "Error."; 
} 

등 모두 코드를 시도 . 내가 어디로 잘못 가고 있니?

답변

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

변경 시간 제한 등

관련 문제