开发者

FBConnect Question?

I just imported all of the newest FBConnect classes into my xCode project and it has no error or warnings. I clicked the box add to group folder too. Now I am stuck. I want to actually get to the coding part of this but all of the tutorials I find on the internet are outdated. All I did so far was #import "FBConnect.h" and thats it. Now what do I do from here just to post a simple status on my wall? Als开发者_StackOverflow社区o how about to upload a photo (UIImage)?

Thanks!


I don't have all the answers for you, but here is how my app posts a status update with an attachment (or in facebook speak "publish_stream"). I created a singleton class called FacebookController within which I call:

    facebookObject = [[Facebook alloc] initWithAppId:apiKey];

and then call this method to obtain permission to post:

    [[FacebookController facebookObject] authorize:[NSArray arrayWithObjects:@"publish_stream",nil] delegate:self];

My app obtains information about the user via this method:

        [[FacebookController facebookObject] requestWithGraphPath:@"me" andDelegate:self];

You will also need to use something like these calls to verify the session validity and store needed information:

[[FacebookController facebookObject] isSessionValid]

NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
[prefs setObject:[[FacebookController facebookObject] accessToken] forKey:@"AccessToken"];
[prefs setObject:[[FacebookController facebookObject] expirationDate] forKey:@"ExpirationDate"];
[prefs synchronize];

And then you will need this method for the actual posting:

[[FacebookController facebookObject] requestWithMethodName:@"Stream.publish" andParams:params andHttpMethod:@"POST" andDelegate:self];

params is a NSDictionary that in my case included a message, attachment, action_links, and a target_id.

I imagine you could include your photo as the attachment, but am not sure exactly what steps you would need to take to do so. In any case, this should get you moving in the right direction.

The Facebook documentation leaves much to be desired unfortunately.

Good luck!

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜