Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/293.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/109.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在变量中存储FQL的值_Php_Facebook Fql - Fatal编程技术网

Php 如何在变量中存储FQL的值

Php 如何在变量中存储FQL的值,php,facebook-fql,Php,Facebook Fql,我正在尝试从用户中提取用户信息。 我可以使用fql获得它。但主要的问题是,我无法将特定的数据(比如名称)存储在单独的变量中 我想在网页的文本框中显示该值。 有人能告诉我怎么了吗 <?php $app_id = '237773783026***'; $app_secret = '90a6514ebed8***f47a3d9a695608315'; $my_url = 'http://apps.facebook.com/anubhawfirst'; $code = $_REQUEST["co

我正在尝试从用户中提取用户信息。 我可以使用fql获得它。但主要的问题是,我无法将特定的数据(比如名称)存储在单独的变量中 我想在网页的文本框中显示该值。 有人能告诉我怎么了吗

<?php
$app_id = '237773783026***';
$app_secret = '90a6514ebed8***f47a3d9a695608315';
$my_url = 'http://apps.facebook.com/anubhawfirst';

$code = $_REQUEST["code"];

// auth user
if(empty($code)) {
$dialog_url = 'https://www.facebook.com/dialog/oauth?client_id=' 
$app_id . '&redirect_uri=' . urlencode($my_url) ;
echo("<script>top.location.href='" . $dialog_url . "'</script>");
}

// get user access_token
$token_url = 'https://graph.facebook.com/oauth/access_token?client_id='
$app_id . '&redirect_uri=' . urlencode($my_url) 
. '&client_secret=' . $app_secret 
. '&code=' . $code;

// response is of the format "access_token=AAAC..."
$access_token = substr(file_get_contents($token_url), 13);

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

//this is the part where am trying to extract using array.
foreach ($fql_query_obj as $item)
{ 

print $fql_query_obj[0];
;
}

// display results of fql query

echo '<pre>';
print_r("query results:");
print_r($fql_query_obj);
echo '</pre>';


?>

您有一个包含查询结果的多维数组。uid和name列中的值有四个级别。按如下方式访问它们:


谢谢你的回复。我添加了,$uid=$fql_query_obj[0]['data'][0]['uid'];echo($uid);在打印语句的最后4行之前,但什么也没有发生。我的意思是它没有显示任何东西。顺便说一句,我没有明确说明数组的大小。那为什么是4级dep呢?我对fql很陌生。:)
$uid = $fql_query_obj[0]['data'][0]['uid'];
$name = $fql_query_obj[0]['data'][0]['name'];