Monday, 30 September 2013

IOS - Facebook score and timeline

IOS - Facebook score and timeline

I'am trying to make facebook leader board for my app.. but i don't under
stand that
WHY NOT PUBLISH NEWSFEED or Any other info to my facebook test user pages?
my source code have any problem? =(
[Sandbox mode/3test user tried/there is no error] Write permission is OK.
Fetching current score is OK.
Score post returns no error and "FACEBOOK_NON_JSON_RESULT" = true;
[self FBRequestWritePermissions];
NSMutableDictionary* params = [NSMutableDictionary
dictionaryWithObjectsAndKeys:
[FBSession
activeSession].accessTokenData.accessToken,@"access_token",

[NSString stringWithFormat:@"%d",
nScore], @"score",
nil];
NSLog(@"Access Token : %@",[FBSession
activeSession].accessTokenData.accessToken);
NSLog(@"Fetching current score");
// Get the score, and only send the updated score if it's highter
[FBRequestConnection startWithGraphPath:[NSString
stringWithFormat:@"/%llu/scores", _myData.idName] parameters:params
HTTPMethod:@"GET" completionHandler:^(FBRequestConnection *connection, id
result, NSError *error) {
if (result && !error) {
int nCurrentScore = 0;
if ([[result objectForKey:@"data"]count] > 0) {
nCurrentScore = [[[[result objectForKey:@"data"]
objectAtIndex:0] objectForKey:@"score"] intValue];
}
NSLog(@"Current score is %d", nCurrentScore);
if (nScore > nCurrentScore) {
NSLog(@"Posting new score of %d", nScore);
[FBRequestConnection startWithGraphPath:[NSString
stringWithFormat:@"/%llu/scores", _myData.idName]
parameters:params
HTTPMethod:@"POST"
completionHandler:^(FBRequestConnection
*connection, id result, NSError *error)
{
NSLog(@"Score posted:%@ \n\n %@
\n\n%@",result,error,_isPublishable==YES?@"YES":@"NO");
}];
}
else {
NSLog(@"Existing score is higher - not posting new score");
}
}
}];
Facebook tutorial saids..
"The process is simple. Each time a player achieves a score in the game,
the game issues an HTTP POST request /USER_ID/scores with a user
access_token. Assuming the user has granted the publish_actions
permission, their score will post to the graph
From there, Facebook can automatically generate several interesting
stories, including high score stories when the player reaches a new high
score, and passing stories when the player overtakes a friend in the
game."
But i don't understand why not post to the graph...?

No comments:

Post a Comment