【问题标题】:graph api posting scores results in 403 forbidden, but only for some users?图 api 发布分数导致 403 被禁止,但仅适用于某些用户?
【发布时间】:2012-06-04 04:56:58
【问题描述】:

所以我成功地让我的应用使用我的帐户将分数发布到 Facebook。但是当我去实施排行榜时,我尝试用我妻子的帐户玩。当它尝试提交她的分数时,它返回“远程服务器返回错误:(403) Forbidden”。经过验证的我的工作仍然正常。可以重复复制。

这是 WCF 服务。

<WebGet()>
<OperationContract()> _
Public Function postMyScore(id, score) As String
    'post user score using user's id, score and app's access_token
    Dim URL As String = "https://graph.facebook.com/" + id + "/scores"
    Dim webProxy As New System.Net.WebProxy(proxyURLremoved, True)
    Dim appToken = getAuthCode()

    Using client As New Net.WebClient
        client.Proxy = webProxy
        Dim reqparm As New Specialized.NameValueCollection
        reqparm.Add("score", score)
        reqparm.Add("access_token", appToken)
        Dim responsebytes = client.UploadValues(URL, "POST", reqparm)
        Dim responsebody = (New Text.UTF8Encoding).GetString(responsebytes)
        Return responsebody
    End Using

End Function

同样,当我以我的身份登录时,上述方法有效,但当我使用我妻子的帐户登录时,上述方法无效

当我尝试使用 Graph API Explorer 复制帖子时,我收到以下错误(可能是出于安全考虑)

{
  "error": {
    "message": "(#240) Requires a valid user is specified (either via the session or via the API parameter for specifying the user.", 
    "type": "OAuthException", 
    "code": 240
  }
}

【问题讨论】:

  • 你老婆的账号是否也授权了你的应用?另外,您检查了访问令牌以确保它们有效?
  • 啊,谢谢您为我指明了正确的方向,有点;)基本上,我将 OAuth 对话框与登录按钮混淆了。我认为在我的网站设置页面中设置权限可以满足我的要求,但我必须在登录按钮的“data-perms”属性中指定它们。

标签: wcf facebook-graph-api


【解决方案1】:

我将应用中心中 OAuth 对话框的权限部分与登录按钮的 data-perms 属性混淆了。它们不是一回事;)

现在我的登录按钮看起来像这样,一切正常。

    <div id="fbLogin"><fb:login-button data-perms="publish_actions,friends_games_activity,user_games_activity" show-faces="false" width="200" max-rows="1"></fb:login-button></div>

显然应用所有者默认拥有所有权限。

【讨论】:

    猜你喜欢
    • 2015-01-19
    • 2012-10-13
    • 2019-02-27
    • 2012-12-24
    • 2021-06-17
    • 2020-11-02
    • 2019-11-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多