Reputation: 291
I have developed a sample project where i am displaying Text and an Image and i am able to post it on facebook wall . I have shown the code and the image of it below .This appears like how we add a photo into our wall with status message
- (IBAction)postStatusUpdateClick:(UIButton *)sender
{
UIImage *image =[UIImage imageNamed:@"[email protected]"];
NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
[params setObject:@"Test with Image" forKey:@"message"];
[params setObject:UIImagePNGRepresentation(image) forKey:@"picture"];
shareOnFacebook.enabled = NO; //for not allowing multiple hits
[FBRequestConnection startWithGraphPath:@"me/photos"
parameters:params
HTTPMethod:@"POST"
completionHandler:^(FBRequestConnection *connection,
id result,
NSError *error)
{
if (error)
{
//showing an alert for failure
[self showAlert:@"Facebook unable to share photo " result:result error:error];
}
else
{
//showing an alert for success
[self showAlert:@"Facebook share photo successful" result:result error:error];
}
shareOnFacebook.enabled = YES;
}];
}
// UIAlertView helper for post buttons
- (void)showAlert:(NSString *)message
result:(id)result
error:(NSError *)error {
NSString *alertMsg;
NSString *alertTitle;
if (error) {
alertTitle = @"Error";
if (error.fberrorShouldNotifyUser ||
error.fberrorCategory == FBErrorCategoryPermissions ||
error.fberrorCategory == FBErrorCategoryAuthenticationReopenSession) {
alertMsg = error.fberrorUserMessage;
} else {
alertMsg = @"Operation failed due to a connection problem, retry later.";
}
} else {
NSDictionary *resultDict = (NSDictionary *)result;
alertMsg = [NSString stringWithFormat:@"Successfully posted '%@'.\nPost ID: %@",
message, [resultDict valueForKey:@"id"]];
alertTitle = @"Success";
}
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:alertTitle
message:alertMsg
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
}
*****Now i want to display in proper format like in the one in scrumptious example from facebook.**
I want to do it without open graph api . Can anyone help me in this
Thanks
Upvotes: 1
Views: 6440
Reputation: 2360
Post Image with Text on FB Wall without using Open Graph API >> http://xcodenoobies.blogspot.com.au/2012/09/how-to-upload-photo-and-update-status.html
Updated Answer
Post Image and Text on facebook using FB iOS SDK https://developers.facebook.com/docs/tutorials/ios-sdk-tutorial/
Cheers, Ravi
Upvotes: 2
Reputation:
Just open this url in mobile safari.It will show share dialog
"http://www.facebook.com/dialog/feed?fbapp_id=yorfbappId&name=Test&description=test&redirect_uri=fbyourfbappid%3A%2F%2Fauthorize&sdk=ios"
Upvotes: 1