Ich bin neu in der Suche nach der Facebook-API. Ich benutze diesen Code, aber der resault ist leer. Kann mir jemand helfen? Vielen Dank.Facebook API Suche.
<form action ="index.php" method ="post">
<input type="text" value="what is?" name="search" style="color:#999;text-align:center;" onfocus="if (value =='what is?'){value =''}" onblur="if (value ==''){value='what is?'}"/>
<input type ="submit" value="ok" />
</form>
<?php
function callFb($url)
{
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true
));
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
$url = "https://graph.facebook.com/oauth/access_token?client_id=api_id&redirect_uri=my_url&client_secret=my_secret";
$access_token = callFb($url);
$access_token = substr($access_token, strpos($access_token, "=")+1, strlen($access_token));
$url1 = "https://graph.facebook.com/search?access_token=".$access_token."&q=".urlencode($_POST['search'])."&type=user";
$ret_json = callFb($url1);
$users = json_decode($ret_json, true);
?>
<img src="https://graph.facebook.com/<? echo $users[data][0][id]; ?>/picture?type=small">
'https: //graph.facebook.com/oauth/access_token? Client_id = api_id & redirect_uri = my_url & client_secret = my_secret' Sie müssen' api_id', 'my_url' und' my_secret' durch entsprechende Daten ersetzen –
@Horia Dragomir, yes Ich habe schon meins ersetzt, aber das ergebnis ist leer, selbst ich suche mich selbst nach name. –
bedeutet '$ access_token' etwas Gültiges? – ajreal