所以我通过应用程序在Facebook页面上发布,但是当我没有登录时,应用程序要求我先登录,我可以运行应用程序而无需登录我的帐户在我的页面上发布吗?
这是我的代码的一部分
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
}
答案 0 :(得分:0)
当您尝试代表授权您的应用程序发布的用户时,您必须使用您通过authresponse发出的accessstoken。此令牌可以存储并用于您的发布需求。
您可以使用FB.getLoginStatus,如果他们已经授权您的应用程序然后使用
,它将返回'connected'var uid = response.authResponse.userID; var accessToken = response.authResponse.accessToken;
检索您需要的数据
编辑:您的“https://graph.facebook.com/oauth/authorize”调用返回[redirect_uri]的页面将包含名为accesstoken和userID的数据,并将这些数据存储在您的应用程序中。此用户标识的accessstoken不会过期,可用于将来发布消息的调用。我是否更好地解释,如果没有,请让我知道哪些部分仍然不清楚。