开发者

How to use the Facebook API, and how can I post a link with status on the users wall via my app?

I'm trying to post a link + status through my app, using this "popup" facebook window where the user is asked to log in, then asked to allow my app to his profile. Then I want him to be able to write a status, with a link I specify attached. This facebook popup would be triggered by a button, not at start of my app (in the documentation I found that they want me to implement it in the appDidFinish launching method...) But I don't want that, I want it like the popup facebook window is only triggered per button tap.

I'm trying to figure this out for a few days now, but finding that all tutorials are out-dated and the Facebook Developer documentation is very weak- atleast for for me. I already downloaded the Facebook-iOS-SDK with the API and JSON included from GitHub. I already did a few attempts, but the furthest I got is that the user was asked to log in, but not through my app, instead Safari opened and the log in field were there, not in my app.

Could someone please post some code, a basic tutorial I might find helpful, or point me to a good online tutorial? I already tried to post to iPhone Dev SDK forums, where other people also asked for this, bu开发者_如何学Ct never got any help. So could someone out here please put together something that would help out all the newbies?

I want my login screen look like this, and the rest should be in a popup too: http://www.facebook.com/photo.php?pid=439332&l=c04b210914&id=100001688115647

Thanks a lot in advance!


There is already a sample code in facebook-ios sdk you can see that there are already the code available for some things. Here is a code snippet from the older facebook API but this should work with the newer graph api too

- (void)setStatus:(id)target {
    NSString *statusString = @"Testing iPhone Connect SDK";
    NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
                            statusString, @"status",
                            @"true", @"status_includes_verb",
                            nil];
    [[FBRequest requestWithDelegate:self] call:@"facebook.users.setStatus" params:params];
}

WHat you can do is create a controller to handle all the facebook requests like a singleton class and on tap of button do something like this

- (IBAction)showFBLoginDialog:(id)sender {
    if(LoggedInFacebook == NO) {
        FBLoginDialog *dlg = [[[FBLoginDialog alloc] initWithSession:faceBookController._session] autorelease];
        [dlg show];
    }
    else {
        [faceBookController logoutUser];
    }

}

If you need further help search on google and stackoverflow you will find a bunch of.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜