아래의 오픈 그래프 호출 코드에 어떤 문제가 있는지 말해 줄 수 있습니까?Open Graph : Java Script : 현재 사용자에 대한 정보를 쿼리하려면 활성 액세스 토큰을 사용해야합니다.
나는 어떤 토큰마다에서 응용 프로그램 토큰, 사용자 토큰과 함께 시도와의 반응 나를
{ "오류": { "메시지": "활성 액세스 토큰에 대한 정보를 쿼리하는 데 사용되어야합니다 현재 사용자 ","형. ""OAuthException ","코드 "2500}} 내가 확인한
응용 프로그램 토큰, 사용자 토큰 및 FB 디버거 내 코드
<?php
$appId = '****************';
$appSecret = '*************************';
$appNameSpace = 'og_loctest';
$token_url = "https://graph.facebook.com/oauth/access_token?" .
"client_id=" . $appId .
"&client_secret=" . $appSecret .
"&grant_type=client_credentials";
$response = file_get_contents($token_url);
$params = null;
parse_str($response, $params);
$access_token = $params['access_token'];
?>
<html xmlns:og="http://ogp.me/ns" xmlns:fb="http://www.facebook.com/2008/fbml" lang="en">
<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# og_loctest: http://ogp.me/ns/fb/og_loctest#">
<meta property="fb:app_id" content="<?php echo $appId;?>" />
<meta property="og:type" content="og_loctest:properties" />
<meta property="og:url" content="http://nirav-metronew.kwetoo.com/fbtest/" />
<meta property="og:title" content="Sample Properties" />
<meta property="og:image" content="https://s-static.ak.fbcdn.net/images/devsite/attachment_blank.png" />
<title>OG Tutorial App</title>
</head>
<body>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : "<?php echo $appId;?>",
status: true,
cookie: true,
xfbml: true,
frictionlessRequests: true,
useCachedDialogs: true,
oauth: true
});
};
// Load the SDK Asynchronously
(function(d){
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
d.getElementsByTagName('head')[0].appendChild(js);
}(document));
function fblogin()
{
FB.login(function(response) {
if (response.authResponse) {
postProperties();
}
},{scope: 'email,offline_access,publish_stream,publish_actions'});
}
function postProperties()
{
FB.api(
'/me/og_loctest:post',
'post',
{ properties: 'http://nirav-metronew.kwetoo.com/fbtest/',access_token:"<?php echo $access_token;?>"},
function(response) {
if (!response || response.error) {
alert('Error occured');
} else {
alert('Facebook open graph tested! Action ID: ' + response.id);
}
});
}
</script>
</head>
<body>
<form>
<input type="button" value="Post properties" onclick="fblogin()" />
</form>
</body>
</html>
덕분에 내 케 응답을 위해 .. 그래 당신은 바로 사람이다하지만 난 응용 프로그램 access_token은 통과하고 그리고 난 응용 프로그램 액세스 토큰이하는 생각으로하지 당신이 언급하고 내가 가진 내가 시도 그런데 사용자 세션 에 따라 달라집니다 내 fb 호출이 응답. { "error": { "message": "(# 15)}이 메소드는 앱 access_token으로 호출해야합니다.", "type": "OAuthException", "code": 15}} –
응용 프로그램 액세스 토큰을 사용할 때'/ me/... '를 사용하여 그래프 API를 작성하십시오. 그러면 API가 "나"가 누구인지 알 수있는 방법이 없기 때문입니다. 대신'/ userid/... '를 호출하십시오. – CBroe
와우 정말 당신은 위대하다 ..... 이건 내게 정말로 작용한다. :) 고마워 .. –