<?php
function curl($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
$status_all = "https://api.facebook.com/method/fql.query?query=SELECT type, app_id, comments, post_id, actor_id, target_id, message, created_time FROM stream WHERE source_id IN (SELECT uid2 FROM friend WHERE uid1=me())&limit=50&format=json&access_token=XXXXXX";
$status_all = json_decode(curl($status_all));
if(count($status_all)>=0){
foreach($status_all as $status){
echo $status->type;
}
}
?>
但它返回:警告:第16行的file.php中为foreach()提供的参数无效
知道为什么会这样吗?
答案 0 :(得分:0)
为了使我的评论更容易,请回答表格,使其格式化,尝试:
$q = urlencode("SELECT type, app_id, comments, post_id, actor_id, target_id, message, created_time FROM stream WHERE source_id IN (SELECT uid2 FROM friend WHERE uid1=me())"
$status_all = "https://api.facebook.com/method/fql.query?query=$q&limit=50&format=json&access_token=XXXXXX";
$status_all = json_decode(curl($status_all));