Note that there are some explanatory texts on larger screens.

plurals
  1. POJS SDK - Posting to a page wall
    primarykey
    data
    text
    <p>I am using the JavaScript SDK. I have an application that has publishing permissions and after certain actions are taken a post will be made to the logged in users wall like so:</p> <pre><code>FB.getLoginStatus(function (response) { //we are authorized if (response.status == "connected") { var name = "Post name"; var body = "Post body"; var caption = "The caption"; var description = "The description"; var link = "http://www.facebook.com/mypage"; FB.api('/me/feed', 'post', { message:body,caption:caption,link:link,name:name,description:description}, function (response) { console.log(response); }); } }); </code></pre> <p>What I would like to able to do is post to a specific Facebook Page after a post is successfully made to the users page. Is there a way to securely pre-authorize an application to do that? Is this possible with the JavaScript SDK, or at all? I did some looking around and havn't found a definite answer. I'm looking at the FB documentation but find it to be a bit spotty in places. Could anyone tell me if this is possible? Any help or advice would be very much appreciated, thanks much! </p> <p><strong>Edit:</strong> my mistake, I should have supplied more info. Here is what I am trying to do:</p> <pre><code>var body = "The body"; var caption = "The caption"; FB.api("mypageid/feed", "post", { message: body, caption: caption }, function (response) { console.log(response); }); </code></pre> <p>I am getting the error <code>"this api call requires a valid app_id"</code> however my page id is valid. When I call <code>FB.init()</code> I am passing my app id and it works for the first post to the logged in users feed. </p> <p><strong>Edit:</strong> </p> <p>I have made the change the Igy suggested. Now I am getting the error:""(#200) The user has not granted the application the permission to automatically publish feed stories""</p> <p>Now, as I said I am trying to post to a Facebook page. I have logged into the account that owns the page and I have gone to the app and clicked allow for the following permissions: </p> <pre><code>email,user_photos,publish_stream </code></pre> <p>When I am logged in with the account that owns the page and check my status:</p> <pre><code>FB.getLoginStatus(function (response) { console.log(response); }); </code></pre> <p>I get "connected". Am I doing this incorrectly? Do I have to do more than just authorize with the account that owns the page? Is there a way to set allow permissions for a page? I did a little digging but couldn't find an answer. </p> <p><strong>Edit</strong> : Ok, now what is happening is IF I am logged into the account that owns the page the post will be made to the page. If I am logged in with another account I get an id back as a response to the API call but it doesn't seem to be a valid object id. For instance I just got this back:</p> <pre><code>id: 499973616681852_507724422573438 </code></pre> <p>if I go to <code>http://graph.facebook.com/499973616681852_507724422573438</code></p> <p>I get an "<code>unsupported get request"</code> graph api exception, which suggest that id returned is not valid. I feel like I am close here but I am missing something. Any advice would be appreciated, thanks again to all who responded. </p> <p>edit: removed the link to the page,that was left in unintentionally. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload