2012-04-11 3 views
1

페이스 북에 게시가 새로 생겼지 만 사용자 계정으로 오프라인으로 게시하는 데 성공했지만 회사 페이지와 함께 오프라인으로 게시 할 수는 없습니다.Facebook - 어떻게 javascript sdk를 사용하여 회사에 게시 할 수 있습니까?

나는 내 자신의 페이스 북 계정을 통해 "Nick Poster App"이라고 불리는 자신의 "Facebook App"을 만들었습니다. 내 개인 페이지와 회사 페이지 모두에 대해 세 가지 권한 (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 '테스트 포스트'와 'sendPost "명령을 수행 할 때 (내가 자리에 내 access_token이를 넣어 제공) 내 개인 계정에 대해 작동합니다. 이것은 내 회사 페이지에서 작동하지 않으며, 왜 (나는 내 ​​acess_token을 집어 넣었습니까)에 대한 손실로 임했습니다.

페이스 벅 (Facebok)도이 사실을 잘 기록하지 못 했으므로 진행하기가 어려워졌으며, 왜 회사 페이지에서이 기능이 작동하지 않는지 이해할 수 있습니까?

미리 감사드립니다.

답변

0
당신은 설정할 수 있습니다

매개 변수는 당신이 "에 게시 응용 프로그램으로 당신의 페이지에 페이지로 게시하고자하는 경우 페이지 파마가 필요합니다 관리하고자하는 페이지를 대상으로"로 ".

<div id="msg"></div> 
<script> 
// uid is the id of the page or user you wish to post to. 
     function feedthis2(uid) { 

     // calling the API ... 
     var obj = { 
     method: 'feed', 
     to: ''+uid+''  
     }; 

     function callback(response) { 
      document.getElementById('msg').innerHTML = "Post ID: " + response['post_id']; 
     } 

     FB.ui(obj, callback); 
     } 
    feedthis2('AnotherFeed'); // to http://facebook.com/anotherfeed 
    //feedthis2('135669679827333'); 
</script> 
+1

다른 사용자 계정에 게시물을 올리려고하지 않고 자체 뉴스 피드에 게시물을 올리거나 "내 페이지에 페이지로 게시"라고 말하면됩니다. "페이지 퍼미션 관리"란 무엇인가요? "offline_access "? 현재 내가 권유하는 유일한 permmisions는"offline_access, read_stream "입니다."publish_stream "도 사용했지만 기쁨은 없습니다. – user1326989

+1

"manage_pages "권한을 얻었으므로 지금 새 access_token을 사용하고 있습니다. 작동하지 않는다. 내 개인 계좌로 일할 때까지. 어떤 아이디어? – user1326989

+0

죄송합니다. 혼란스러워서 페이지에 페이지로 게시하려면 페이지로 로그인하고 페이지 액세스 토큰을 받아야합니다. https://developers.facebook.com/docs/authentication/pages/ 페이지를 추가하십시오. acce3ss 토큰 페이지를 &에서 페이지 ID로 설정하십시오. 그런 다음 게시물이 작동해야합니다. –

관련 문제