【问题标题】:Posting on user's timeline on the behalf of the user代表用户在用户的时间线上发布
【发布时间】:2012-11-21 12:45:48
【问题描述】:

我在 Facebook 上创建了 APP。

现在我正在尝试使用 Graph API 在用户的时间轴上发表评论,但我无法理解我需要做什么。

我已经授权了应用程序(我授权了这个权限:'user_status,publish_stream,user_photos,email')。

如果我查看我的个人资料 -> 隐私,我可以看到 APP 可以:

This app can: Post on your behalf
This app may post on your behalf, including status updates, photos and more.

Last data access:   
Basic InformationToday
See details · Learn more
Posts on your behalf:   
Who can see posts this app makes for you on your Facebook timeline? 
Public
Notifications:  
When to notify you? 
The app sends you a notification

所以这部分看起来还可以。

在我的应用程序中,我执行以下操作以尝试在我的时间轴上发布某些内容(我需要在离线时发布)。

1) 获取:https://graph.facebook.com/oauth/access_token?client_id=APPID&client_secret=*APP_SECRET*&grant_type=client_credentials

回应:

access_token = 422828347771671|UdQELQIf0N7krF4JUo7VwtPLTkk

2) 获取:https://graph.facebook.com/search?q=myemail&type=user

回应:

_"error":_{
______"message":_"A_user_access_token_is_required_to_request_this_resource_",
______"type":_"OAuthException",
______"code":_102
___}

但是阅读文档 (https://developers.facebook.com/docs/reference/api/#searching) 似乎这个请求不需要任何类型的访问令牌。

我也尝试添加访问令牌,但结果还是一样。

3) 我知道我的 facebookid,所以我尝试直接使用它:

发布:https://graph.facebook.com/100001139132403/feed

参数:

access_token=422828347771671|UdQELQIf0N7krF4JUo7VwtPLTkk,

message=你好

回应:

   "error": {
      "message": "(#200) This API call requires a valid app_id.",
      "type": "OAuthException",
      "code": 200
   }
}

所以我尝试添加 client_id=APPIDapp_id=APPID,我尝试将一个、另一个以及两个参数都设置为 GET 或 POST,但没有任何改变。

我检查了 APPId 广告是正确的。

有人知道吗?

谢谢!

【问题讨论】:

    标签: facebook api facebook-graph-api


    【解决方案1】:

    您不能简单地通过查询 URL 来生成用户 access_token。您所做的事情提供了 App 访问令牌,正如错误所说,您正在尝试做一些需要用户 access_token 的事情。

    参考并实施:https://developers.facebook.com/docs/howtos/login/server-side-login/

    并将该 access_token 用于其余进程。

    【讨论】:

      猜你喜欢
      • 2012-03-20
      • 2017-11-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多