Facebookの投稿は初めてですが、ユーザーアカウントを使用してオフラインで投稿することには成功しましたが、会社のページを使用してオフラインで投稿することはできません.
私は自分の個人的な Facebook アカウントを介して「ニックス ポスター アプリ」と呼ばれる独自の「Facebook アプリ」を作成しました。個人用ページと会社用ページの両方について、アプリに 3 つのアクセス許可 (offline_access、read_stream、publish_stream) を付与しました。アカウントごとに次の手順に従ってこれを行いました...
Creating the app...
1. Login to facebook with the account you want linked to the app
2. Follow this link http://www.facebook.com/developers/apps.php#!/developers/createapp.php
3. Create your app and take a note of you App Id and your App secret Id.
Giving the correct rights to the app and getting the access_token..
Method 1:
1. Get the account in question to login to facebook
2. However you like, direct the user to this link (replacing <App-Id> with the App Id of the created app) https://graph.facebook.com/oauth/authorize?client_id=<App-Id>&scope=offline_access,read_stream&redirect_uri=http://www.facebook.com/connect/login_success.html
3. Take a note of the result of the “code” querystring.
4. Goto this url (replace “<APP-ID>” with you appId and “<APP-SECRET>” with your apps secret id and “<code>” with the copied code)
https://graph.facebook.com/oauth/access_token?client_id=<APP-ID>&redirect_uri=http://www.facebook.com/connect/login_success.html&client_secret=<APP-SECRET>&code=<code>
5. Copy what you see, minus the expires querystring. That is your access_token.
両方のアカウントのアクセス トークンを取得した後、このコードを使用して投稿を行いました。
<!-- FACEBOOK -->
<div id="fb-root"></div>
<script>
(function () {
var e = document.createElement('script');
// replacing with an older version until FB fixes the cancel-login bug
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
//e.src = 'scripts/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
} ());
</script>
<!-- END-OF-FACEBOOK -->
<script>
//initialise
window.fbAsyncInit = function () {
FB.init({
appId: '351023398277068',
status: true, // check login status
cookie: true, // enable cookies to allow the server to access the session
xfbml: true, // parse XFBML
oauth: true // Enable oauth authentication
});
};
function sendPost(inMessage) {
var opts = {
message: inMessage,
access_token: '<SAVED-TOKEN>'
};
FB.api('/me/feed', 'post', opts, function (response) {
if (!response || response.error) {
alert('Posting error occured');
}
else {
alert('Success - Post ID: ' + response.id);
}
});
}
</script>
perameter 'Test post' を指定して "sendPost" コマンドを実行すると、個人アカウントで機能します (access_token を配置した場合)。これは私の会社のページでは機能せず、理由がわかりません(acess_tokenを配置しています)。
Facebookもこれをうまく文書化しておらず、進歩を難しくしています.これが会社のページでうまくいかない理由を誰か理解していますか?
前もって感謝します。