Reputation: 201
I am using Facebook SDK plugin for social sharing in my app.
I am able to logged in and sharing photos on user wall.
I want to upload that image on the Facebook which I have created from facebook account. Is there is Facebook API for sharing image on the facebook page.
Please help, for example my facebook page Url is https://www.facebook.com/demoneptune/ Thanks.
Upvotes: 1
Views: 661
Reputation: 584
You need some permissions from facebook, most important permission is "publish_actions".
You need page_ID of that facebook page to which you want to post.
Then try this:
NSMutableDictionary *params = [NSMutableDictionary dictionary];
[params setObject:@"Your own message" forKey:@"message"];
[params setObject:@"facebook_page_id_path_string" forKey:@"place"];
[[[FBSDKGraphRequest alloc] initWithGraphPath:@"/me/feed" parameters:params HTTPMethod:@"POST"] startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
NSLog(@"result %@",result);
NSLog(@"error %@",error);
if (!error) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"Posted!" delegate:self cancelButtonTitle:nil otherButtonTitles:nil];
[alert show];
double delayInSeconds = 1.0;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
[alert dismissWithClickedButtonIndex:0 animated:YES];
});
} else {
NSString *message = @"There was a problem sharing. Please try again!";
[[[UIAlertView alloc] initWithTitle:nil message:message delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] show];
}
}];
Hope this helps.
Upvotes: 1