1つのアプリケーションが特定のファンページにインストールされていて、インストールされていない場合はインストールしたいと考えています。 何らかの理由で私はページアクセスを取得できませんトークン。別のアプリケーションをインストールする
ユーザーアクセストークンとユーザーIDを取得できましたが、ページアクセストークンが「例外」「不明なフィールド:access_token」を返します。
ここで何が間違っていますか? http://developers.facebook.com/docs/reference/api/page/#tabs https://developers.facebook.com/docs/authentication/
<html>
<head>
</head>
<body>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '188474844587139',
status : true,
cookie : true,
xfbml : true,
oauth : true,
});
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
var uid = response.authResponse.userID;
var userAccessToken = response.authResponse.accessToken;
console.log("User Access Token: "+userAccessToken);
console.log("User ID: "+uid);
// get page access token
FB.api('https://graph.facebook.com/'+uid+'/accounts?access_token='+userAccessToken, function(response) {
console.log(response);
var pageAccessToken = 'Need to get from the response...';
// get information if user got this app
FB.api("https://graph.facebook.com/102561956524622/tabs/353470634682630?access_token="+pageAccessToken,
function(data) {
console.log(data);
});
// install the app
var params = {};
params['app_id'] = '353470634682630';
FB.api('https://graph.facebook.com/102561956524622/tabs'+pageAccessToken, 'post', params, function(response) {
if (!response || response.error) {
console.log("Error: "+response);
} else {
console.log("Ok: "+response);
}
});
});
} else if (response.status === 'not_authorized') {
console.log("the user is logged in to Facebook, but not connected to the app.");
} else {
console.log("the user isn't even logged in to Facebook.");
}
});
};
(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));
</script>
</body>
</html>
ちょうどここにコードを投げるとは対照的に、あなたは本当にあなたのソリューションを説明しなければなりません。これは技術的に解決策になるかもしれませんが、非常に有益な答えではありません。 – Lix
質問にお答えすることをお勧めしません! (これはあなたの最初の答えです)。良質の回答を与えるように注意してください。 – Lix
あなたは正しいです、私はすぐに説明します.. – DanR