Riyaz saifi
Riyaz saifi

Reputation: 89

how to check user id is verified or not graph api

i want check user verified his/her email,phone or not using verified tag i am trying to delete all non verified user from my site i was use this code but it does not work for me please take a look

$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;

?>

Upvotes: 1

Views: 160

Answers (1)

Riyaz saifi
Riyaz saifi

Reputation: 89

Finally i fount it by my self

<?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
?>

Upvotes: 1

Related Questions