Reputation: 1557
I want to post status on my Facebook page. Status should be shown on Facebook as a page status not status from any username or from my name.
I tried below code,
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:@"This is a check for page post message", @"message", nil];
/* make the API call */
[FBRequestConnection startWithGraphPath:@"/1521177224766299/feed"
parameters:params
HTTPMethod:@"POST"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error){
if (result)
{
NSLog(@"Result %@", result);
}
else
{
NSLog(@"%@", error);
}
}];
a message status was posted done page wall but that status come from my name. But when I tried to hit same post method with page_id/feed POST Query and with same parameter @"this is my status" @"message" from graph api explorer page, it posted status from page not from me.
Please help.
Upvotes: 1
Views: 141
Reputation: 1557
Here is Complete Answer
NSString *accesstoken = <Facebook_Page_Access_Token>
NSDictionary* params = [NSDictionary dictionaryWithObjectsAndKeys:
@"Post heading", @"name",
accesstoken, @"access_token",
@"Type post message", @"message",
@"Hyperlink to your post", @"link",
@"Add description", @"description",
@"Image url string", @"picture",
nil];
FBRequest *requestToPost = [[FBRequest alloc] initWithSession:nil
graphPath:@"/me/feed"
parameters:params
HTTPMethod:@"POST"];
FBRequestConnection *requestToPostConnection = [[FBRequestConnection alloc] init];
[requestToPostConnection addRequest:requestToPost completionHandler:^(FBRequestConnection *connection, id result, NSError *error)
{
if (!error) {
NSLog(@" %@", result);
}
else
{
NSLog(@"%@", error);
}
}];
Upvotes: 0
Reputation: 82759
NSString *accesstoken=[NSString stringWithFormat:@"%@","here add your page access_token"];
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
accesstoken, @"access_token",
postingString, @"message",
// @"http://www.real-timesports.com", @"link",
nil];
FBRequest *requestToPost = [[FBRequest alloc] initWithSession:nil
graphPath:@"/me/feed"
parameters:params
HTTPMethod:@"POST"];
NSLog(@"requestToPost==%@",requestToPost);
FBRequestConnection *requestToPostConnection = [[FBRequestConnection alloc] init];
[requestToPostConnection addRequest:requestToPost completionHandler:^(FBRequestConnection *connection, id result, NSError *error)
{
NSLog(@"facebook result >> %@", result);
}];
[requestToPostConnection start];
Upvotes: 1