0
<?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() 提供的参数无效

知道为什么会这样吗?

4

1 回答 1

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));
于 2013-04-02T05:44:55.907 回答