我想要做的就是这样的POST:
只要您具有publish_actions权限,就可以通过使用应用程序access_token向/ USER_ID / scores发出HTTP POST请求来发布乐谱或用户。
名称说明类型必填
分数数值分数,其值>0。整数是
我正在这样做:
try {
http.request( POST, URLENC ) {
uri.path = "/100000781309474/scores?" + user.accessToken
body = [score:10]
response.success = { resp ->
println "Tweet response status: ${resp.statusLine}"
assert resp.statusLine.statusCode == 200
}
response.failure = { resp ->
println "Unexpected error: ${resp.status} : ${resp.statusLine.reasonPhrase}"
}
}
} catch ( HttpResponseException ex ) {
// default failure handler throws an exception:
println "Unexpected response error: ${ex.statusCode}"
}
但它返回此异常:
400: Bad request
这意味着POST不正确,是吗?
有人可以告诉我如何根据用户评分来发布帖子吗?
最佳答案
引用https://developers.facebook.com/docs/score/
我首先看到您正在传递用户 token uri.path = "/100000781309474/scores?" + user.accessToken
它应该是应用访问 token 。格式为http://graph.facebook.com/{userId}/scores?access_token={AppAccessToken}
,参数名称为score
,值为{theirScore}
。确保access_token是应用访问 token 。另外,请确保您的应用已注册为游戏应用。
关于http - 如何发布Facebook成绩?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8963591/