PHP API array loop

I'm trying a loop through a Facebook Graph API loop via a foreach loop but I'm getting this error: "PHP Parse error: syntax error, unexpected T_VARIABLE, expecting T_CATCH".

Any thoughts?

Here's the code:

// 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++;
}

你有你的评论,并期待赶上


你有一个尝试块没有捕获。

try {
$username = $friend_id;
$uservar = '/'.$username.'/likes?fields=id,category&limit=20';
$userlikes = $facebook->api($uservar);
} catch {

//exception happened
}

你似乎已经注释掉了“catch”,重新启用它,并且分析错误将消失。

链接地址: http://www.djcxy.com/p/69812.html

上一篇: 如何从数据库中回显多个结果

下一篇: PHP API数组循环