如何检查用户ID是否已经过验证图形api

时间:2016-06-28 09:12:19

标签: facebook-graph-api

我希望检查用户使用verified标记验证了他/她的电子邮件,电话与否 我试图从我的网站删除所有未经验证的用户我使用此代码,但它不适合我请看看

$result = mysql_query("SELECT * FROM token_all");
if($result){
while($row = mysql_fetch_array($result))
{
$token = $row[token];

$userData = json_decode(file_get_contents('https://graph.facebook.com/me?fields=name,id,verified&access_token='.$token.''),true);print($userData[name]).'<br/>';
if(!$userData[verified]){
$i++;
mysql_query("
DELETE FROM
token_all
WHERE
token='" . mysql_real_escape_string($token) . "'
");
 }
 }
 }
echo $i;

?>

1 个答案:

答案 0 :(得分:1)

最后,我用自己来装扮它

<?php



function get_html($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_FAILONERROR, 0);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}

$i=0; //Dead Token Counter
$result = mysql_query("SELECT * FROM token_all");
if($result){
while($row = mysql_fetch_array($result))
{
$token = $row[token];



if($token){
$graph_url ="https://graph.facebook.com/me?fields=id,name,verified&access_token=" . $token;
$user = json_decode(get_html($graph_url));
print($user->name).'<br/>';
}


$true = $user->verified;
$name = $user->name;

if ($true == true or !$name){
echo "";
}else{ 
$i++;
mysql_query("DELETE FROM token_all WHERE token='". mysql_real_escape_string($token) . "'
");

 }

}
}
echo $i //print DEad tokens value
?>