سؤال

I am using the Facebook SDK for .Net to get posts,likes and comments of a Facebook Page. That work's brilliantly.

However when I try to publish a post to the page - it fails on an oauth 2500 exception.

After some research I learnt I need to get extended permissions ("publish_stream") by confirming via a login pop up that I am an Admin on that Page.

That's all well.

However I am using a Service that does automated publishing of posts and images.

The service that I am using is Developed in VS2013 using C#.

Is there a way for getting a User Access Token to publish a post on a Page without a Login popup.

There are other articles that mention using a web browser control to login and intercepting the navigated event.

Other's mention using a HttpWebRequest.

These posts are fairly old - and I am wondering if there might be different techniques out there.

هل كانت مفيدة؟

المحلول

You can post to a page with an Page Access Token, as described in the docs here: https://developers.facebook.com/docs/graph-api/reference/v2.0/page/feed/#publish

A page access token with publish_actions permission can be used to publish new posts on behalf of that page.

You can get the Page Access Token by issuing

GET /me/accounts

with the publish_actions permission (see docs here: https://developers.facebook.com/docs/facebook-login/access-tokens/). Then, exchange the short-lived token to a long lived one:

GET /oauth/access_token?  
    grant_type=fb_exchange_token&           
    client_id={app-id}&
    client_secret={app-secret}&
    fb_exchange_token={short-lived-token} 

as described here: https://developers.facebook.com/docs/facebook-login/access-tokens/#extending

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top