0

我想以用户友好的方式显示来自 Facebook 的查询结果。

例如,我想显示照片而不是它的链接。

这是我的代码:

//fql query example using legacy method call and passing parameter

try{
$fql = "select name, hometown_location, sex, pic_square from user where uid=" . $user;
$param = array(
'method' => 'fql.query',
'query' => $fql,
'callback' => ''
);
$fqlResult = $facebook->api($param);

}
catch(Exception $o){
d($o);

}

当我这样做时print_r,以下内容显示为:

FQL Query Example by calling Legacy API method "fql.query" Array ( [0] => Array ( [name] => Mohamed Abdelrahman [hometown_location] => [sex] => male [pic_square] => http://profile.ak.fbcdn.net/hprofile-ak-prn1/623888_100000415601915_463726603_q.jpg ) )

或者当我使用:

foreach ($fqlResult as $a => $b)
{

print "$a: $b\n";
}

它输出:

0: Array

感谢大家的回答,我自己解决了这个问题,这是解决方案

foreach($fqlResult as $inner_arr)
foreach($inner_arr as $value)
echo "$value<br/>";
4

2 回答 2

0

请使用更新的方法和代码

//run fql query
    $fql_query_url = 'https://graph.facebook.com/'
        . 'fql?q=SELECT+uid2+FROM+friend+WHERE+uid1=me()'
        . '&access_token=' . $access_token;
    $fql_query_result = file_get_contents($fql_query_url);
    $fql_query_obj = json_decode($fql_query_result, true);

您可以在https://developers.facebook.com/docs/technical-guides/fql/上遵循完整教程

于 2013-04-12T19:54:18.087 回答
0

FQL Query Example by calling Legacy API method "fql.query" Array ( [0] => Array ( [name] => Mohamed Abdelrahman [hometown_location] => [sex] => male [pic_square] => http://profile.ak.fbcdn.net/hprofile-ak-prn1/623888_100000415601915_463726603_q.jpg ) )

在你的情况下,$fqlResult是你的数组。$a是您的键[0],对应的值 ,是包含、、和$b的数组。namehometown_locationsexpic_square

如果要为此显示照片,则$fqlResult需要将 img src 设置为$b['pic_square']

于 2013-04-12T20:01:15.047 回答