0

So I'm posting on a facebook page through an application, but when i'm not logged in the application asks me to login first, can i run the application without having to login to my account to post on my page?

here's part of my code

string app_id = "app_id";
string app_secret = "app_secret";
string scope = "publish_stream,manage_pages,share_item,offline_access";

if (Request["code"] == null)
{
    Response.Redirect(string.Format(
        "https://graph.facebook.com/oauth/authorize?client_id={0}&redirect_uri={1}&scope={2}",
        app_id, Request.Url.AbsoluteUri, scope)); //here it requests me to login
}
else
{
    //rest of code here
}
Chris Schiffhauer
  • 17,102
  • 15
  • 79
  • 88
Arshtat
  • 53
  • 6
  • Refer to this Stackoverflow question. http://stackoverflow.com/questions/17390240/post-on-facebook-pages-wall-without-having-to-login-c – broguyman Feb 24 '14 at 17:09
  • well i did as it's said but i already get a page token in my code, but when i tried that post's code i can't retrieve a page token. – Arshtat Feb 24 '14 at 17:51

1 Answers1

0

You must use the accesstoken via authresponse you received when the user you are trying to post on behalf of authorized your application. This token can be stored and used for your posting needs.

you can use FB.getLoginStatus which will return 'connected' if they have given authorization to your application then you use

var uid = response.authResponse.userID; var accessToken = response.authResponse.accessToken;

to retrieve the data you need

EDIT: the page that your "https://graph.facebook.com/oauth/authorize" call returns to [redirect_uri] will contain data called the accesstoken and userID, store these in your application. This userid's accesstoken does not expire and can be used for the future calls to post messages. did I explain better, if not please let me know what part is still unclear.

Talspaugh27
  • 973
  • 9
  • 16