我正在嘗試通過一個foreach循環通過Facebook圖形API循環,但我得到這個錯誤:「PHP解析錯誤:語法錯誤,意外的T_VARIABLE,期待T_CATCH」。PHP API數組循環
有什麼想法?
下面的代碼:
// WRITING FIRST 50 FRIENDS LIKES
$i = 0;
foreach($userfriends[data] as $value) {
if($key == "id"){
$friend_id = $value;
}
try {
$username = $friend_id;
$uservar = '/'.$username.'/likes?fields=id,category&limit=20';
$userlikes = $facebook->api($uservar);
}
// catch (FacebookApiException $e) {
// error_log($e);
// }
$id = $userlikes[$i][id];
$cat = $userlikes[$i][category];
// WRITING FRIEND LIKES TO DATABASE
$sql="INSERT INTO likes (like_id, category, friend_id) VALUES ('$id', '$cat', '$friend_id');";
mysql_query($sql,$con);
mysql_free_result($sql);
$i++;
}
趕上現在的好搭檔 – mhawk 2011-05-05 23:51:08
@mhawk是否解決了這個問題? – mcgrailm 2011-05-11 00:28:10