开发者

Extract current facebook username using iOS SDK 4

I am using Graph API to get facebook user information as follows:

[facebook requestWithGraphP开发者_如何学Goath:@"me" andDelegate:self];

How can I do this? I know that server response is in the form of JSON object but don't know how to parse it.


I don't find the links that helped me to resolve this issue.

This is the code I used (request:didLoad: is a FBRequestDelegate callback):

- (void)request:(FBRequest *)request didLoad:(id)result {
if ([result isKindOfClass:[NSDictionary class]]) {

    NSDictionary* hash = result;

    NSString *username = (NSString*)[hash valueForKey:@"name"];

    [[NSUserDefaults standardUserDefaults] setObject:username forKey:@"Username"];
}
[self publishStream]; // publishStream is a custom methods of mine to create the post to publish
};

I remember that I read the FB ios api code and maybe this and this

I hope this works for you.

Bye,

Fran


I have answered this question here How to retrieve Facebook response using Facebook iOS SDK

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜