我用图形 api 创建了一个 facebook place serach。但是访问密钥每两个小时过期一次。为此,我实现了以下代码
$app_id = "---";
$app_secret = "----";
$my_url = "";
$code = $_REQUEST["code"];
if (isset($code)) {
$token_url="https://graph.facebook.com/oauth/access_token?client_id="
. $app_id . "&redirect_uri=" . urlencode($my_url)
. "&client_secret=" . $app_secret
. "&code=" . $code . "&display=popup";
$response = file_get_contents($token_url);
$params = null;
parse_str($response, $params);
$access_token = $params['access_token'];
}
$FacebookGraphURL = 'https://graph.facebook.com/search?fields=id,username,name,category,website,likes,location&q='.$keyword.'&type=place¢er='.$center.'&distance='.$radius.'&limit=5&access_token='.$access_token;
$FacebookGraphJSON = file_get_contents($FacebookGraphURL);
但这给出了以下错误:
Notice: Undefined index: code in /opt/lampp/htdocs/APIcomparison/facebook_graph.php on line 24
我错过了什么?另一件事我不知道如何使用 $my_url
谢谢是提前。