开发者

In iPhone App, How to post a photo to a Facebook fan page. Before it how to like it? using facebook-ios-sdk

开发者 https://www.devze.com 2023-02-17 15:37 出处:网络
Using https://github.com/facebook/facebook-ios-sdk, how can I post 开发者_如何学JAVAa photo to a facebook fan page. And before it, how can let a user become a fan of the page (i.e. like)?

Using https://github.com/facebook/facebook-ios-sdk, how can I post 开发者_如何学JAVAa photo to a facebook fan page. And before it, how can let a user become a fan of the page (i.e. like)?

Even though I searched many web pages including stackoverflow, I couldn't find the way. Some answers said that it was not possible. But as you know, you can do these two things in the Facebook app.

[1] Post a post Just post a text is possible like the following code. 153120444748228 is a page id.

[_facebook requestWithGraphPath:@"153120444748228/feed"
     andParams:params
     andHttpMethod:@"POST"
     andDelegate:self];

But I tried to post a photo like above approach, the photo was posted on my wall instead.

NSString *path = @"http://php.chol.com/~sssang/zbxe/files/attach/images/12637/068/015/%ED%8B%B0%EC%95%84%EB%9D%BC-%EC%A7%80%EC%97%B0.jpg";
    NSURL *url = [NSURL URLWithString:path];
    NSData *data = [NSData dataWithContentsOfURL:url];
    UIImage *img  = [[UIImage alloc] initWithData:data];

    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                   @"Post a Picutre to a Fan Page", @"message",
                                   img, @"source",
                                   nil];

    // post a picutre to a page

    [_facebook requestWithGraphPath:@"153120444748228/photos"
                          andParams:params
                      andHttpMethod:@"POST"
                        andDelegate:self];

[2] Become a fan of a page. I tried to do it like the following, nothing happened. :(

NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                               @"http://www.facebook.com/pages/AlonesTest/153120444748228", @"url",
                               nil];

[_facebook requestWithGraphPath:@"153120444748228/likes"
                      andParams:params
                  andHttpMethod:@"POST"
                    andDelegate:self];


check my detailed answer here Posting photos to Facebook fan page with iOS SDK

You actually need to replace your faceBook accessToken with fanPage accessToken by

[_facebook setAccessToken:_accessTokenForFanPage];
0

精彩评论

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