문제

All I want is to do a POST like this:

You can post a score or a user by issuing an HTTP POST request to /USER_ID/scores with the app access_token as long as you have the publish_actions permission.

Name Description Type Required score numeric score with value > 0. integer yes

I am doing this:

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}"
}

but it's returning this exception:

400: Bad request

It means that the POST isn't correct, yes?

Can someone tell me how to do the post with the user score?

도움이 되었습니까?

해결책

Referring to https://developers.facebook.com/docs/score/

I first see you're passing in the user token

uri.path = "/100000781309474/scores?" + user.accessToken

It should be the app access token. The format is http://graph.facebook.com/{userId}/scores?access_token={AppAccessToken} with parameter name of score and value of {theirScore}. Be sure that access_token is an app access token. Also be sure your app is registered as an game app.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top