I am using facebook SDK 3.13 for posting on user's friends wall using fbwebdialogs. When i set params for this dialog it does not show them on dialog.
NSMutableDictionary *params=[NSMutableDictionary new];
FBSession *ses=[FBSession activeSession];
[params setValue:#"hello" forKey:#"caption"];
[params setValue:#"hello" forKey:#"decription"];
[params setValue:#"whats" forKey:#"name"];
[params setValue:#"http://i.imgur.com/g3Qc1HN.png" forKey:#"picture"];
[params setValue:#"http://www.dsvv.org" forKey:#"link"];
[FBWebDialogs presentFeedDialogModallyWithSession:ses parameters:params handler:^(FBWebDialogResult result,NSURL *url,NSError *error){
if (error) {
}
}];
}
it does not identify these link and produce an error. If someone who posted on user's friends wall please notify me regarding this.
str_link = #"www.google.com";
NSString *str_img = [NSString stringWithFormat:#"%#uploads/%#-5.jpg",app.Main_url,[Data_Dict objectForKey:#"deal_id"]];
//NSLog(#"%#",str_img);
NSDictionary *params = #{
#"name" : str_name,
#"caption" : #"",
#"description" : #"",
#"picture" : str_img,
#"link" : str_link,
#"to":str_id,
};
// Invoke the dialog
[FBWebDialogs presentFeedDialogModallyWithSession:nil
parameters:params
handler:
^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
if (error) {
NSLog(#"Error publishing story.");
[self.indicator stopAnimating];
} else {
if (result == FBWebDialogResultDialogNotCompleted) {
NSLog(#"User canceled story publishing.");
[self.indicator stopAnimating];
} else {
NSLog(#"Story published.");
[self.indicator stopAnimating];
}
}}];
Related
I am using AddThis from the following page: http://www.douglasstratton.com/Beaches/Amnesia/flypage.tpl.html
When sharing from the desktop, the image shares fine, but when sharing from iOS, the image is blank on the facebook wall.
Has anyone else had this issue?
You can share with this code.Only import #import <FacebookSDK/FacebookSDK.h>:-
// Put together the dialog parameters
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
APP_NAME, #"name",
self.strSerialName , #"caption",
modelObject.strChapterDescription, #"description",
#"", #"link",
modelObject.strChapterImage, #"picture",
nil];
// Show the feed dialog
[FBWebDialogs presentFeedDialogModallyWithSession:nil
parameters:params
handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
if (error) {
// An error occurred, we need to handle the error
// See: https://developers.facebook.com/docs/ios/errors
NSLog(#"Error publishing story: %#", error.description);
} else {
if (result == FBWebDialogResultDialogNotCompleted) {
// User cancelled.
NSLog(#"User cancelled.");
} else {
// Handle the publish feed callback
NSDictionary *urlParams = [self parseURLParams:[resultURL query]];
if (![urlParams valueForKey:#"post_id"]) {
// User cancelled.
NSLog(#"User cancelled.");
} else {
// User clicked the Share button
NSString *result = [NSString stringWithFormat: #"Posted story, id: %#", [urlParams valueForKey:#"post_id"]];
NSLog(#"result %#", result);
}
}
}
}];
I was wondering if it is possible to send direct Facebook messages from one user to another using Facebook's API on iOS. If not is there any work arounds, could I get permission from Facebook.
Thanks in advance.
Ben.
str_id = [[app.Arr_Facebook_Frnd objectAtIndex:indexpath] objectForKey:#"id"];
str_name = [[app.Arr_Facebook_Frnd objectAtIndex:indexpath] objectForKey:#"name"];
str_link = #"www.google.com";
NSDictionary *params = #{
#"name" : str_name,
#"caption" : #"",
#"description" : #"",
#"picture" : #"",
#"link" : str_link,
#"to":str_id,
};
// Invoke the dialog
[FBWebDialogs presentFeedDialogModallyWithSession:nil
parameters:params
handler:
^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
if (error) {
NSLog(#"Error publishing story.");
[self.indicator stopAnimating];
} else {
if (result == FBWebDialogResultDialogNotCompleted) {
NSLog(#"User canceled story publishing.");
[self.indicator stopAnimating];
} else {
NSLog(#"Story published.");
[self.indicator stopAnimating];
}
}}];
[self.indicator stopAnimating];
I used following code to invite a friend to my app:
NSString *facebookID = user.id;
NSMutableDictionary* params =
[NSMutableDictionary dictionaryWithObject:facebookID forKey:#"to"];
NSString *message = #"SOME_MESSAGE";
NSString *title = #"TITLE";
FBSession *facebookSession = [PFFacebookUtils session]; //You may changed this if you are not using parse.com
[FBWebDialogs presentRequestsDialogModallyWithSession:facebookSession
message:message
title:title
parameters:params handler:
^(FBWebDialogResult result, NSURL *resultURL, NSError *error)
{
if (!error) {
NSLog(#"Succees:%#",resultURL);
}
}]; }
Opens WebDialog as shown:
But I see no invitation on my profile. How do I get it done properly?
str_id = [[app.Arr_Facebook_Frnd objectAtIndex:indexpath] objectForKey:#"id"];
str_name = [[app.Arr_Facebook_Frnd objectAtIndex:indexpath] objectForKey:#"name"];
str_link = #"www.google.com";
NSDictionary *params = #{
#"name" : str_name,
#"caption" : #"",
#"description" : #"",
#"picture" : #"",
#"link" : str_link,
#"to":str_id,
};
// Invoke the dialog
[FBWebDialogs presentFeedDialogModallyWithSession:nil
parameters:params
handler:
^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
if (error) {
NSLog(#"Error publishing story.");
[self.indicator stopAnimating];
} else {
if (result == FBWebDialogResultDialogNotCompleted) {
NSLog(#"User canceled story publishing.");
[self.indicator stopAnimating];
} else {
NSLog(#"Story published.");
[self.indicator stopAnimating];
}
}}];
[self.indicator stopAnimating];
you didn't mention if the console printed "Success...." or not.
anyway, if the request is successfull users will see it only on fb mobile app
I have followed this link to post on friends wall but its not posting actually instead it just lists the no of friends and allows for multiple selection of friends, there is no option for posting on friends wall.
Not getting satisfactory answer please help me how to post on friends wall using FBWebDialogs, as other ways using Graph api to post on users wall is disabled by facebook.
Any help would be much appreciated. Thanks.
Finally I got the answer of my own question, how easier it was !! but it took my couple of days reaching out there.
To post on your friends wall first of all you need is a permission publish_actions.
And here is the simple code :
NSMutableDictionary *params = [NSMutableDictionary new];
[params setObject:#"YOUR DESC" forKey:#"description"];
[params setObject:#"YOUR LINK" forKey:#"link"];
[params setObject:#"YOUR CAPTION" forKey:#"caption"];
[params setObject:#"FRIEND_ID" forKey:#"to"];
[FBWebDialogs presentFeedDialogModallyWithSession:nil
parameters:params
handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
NSLog(#" RESULT : %u",result);
}
];
Make sure you have added Facebook SDK in you bundle
and have imported necessary class.
That's it..
Look on this,
NSDictionary *params = #{#"name" :#"Your name",
#"caption" : #"",
#"description" :#"Your description"],
#"picture" : #"Your Image link",
#"link" : #"Your link",
};
// Invoke the dialog
[FBWebDialogs presentFeedDialogModallyWithSession:nil
parameters:params
handler:
^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
if (error) {
NSLog(#"Error publishing story.");
} else {
if (result == FBWebDialogResultDialogNotCompleted) {
NSLog(#"User canceled story publishing.");
} else {
NSLog(#"Story published.");
}
}}];
I'm using facebook sdk to post on friend's wall. I am able to post it but when i select multiple friends in FBWebDialog instead of posting two friends simultaneously for each friend a separate dialog box is shown. How to post on multiple friend's wall .
-(void)showFriendsList
{
friendPickerController = [[FBFriendPickerViewController alloc] init];
friendPickerController.title = #"Pick Friends";
friendPickerController.delegate = self;
[friendPickerController loadData];
}
-(IBAction)facebookShare:(UIButton *)sender
{
[friendPickerController presentModallyFromViewController:self animated:YES handler:
^(FBViewController *sender, BOOL donePressed) {
if (!donePressed)
{
return;
}
NSString* fid;
NSString* fbUserName;
for (id<FBGraphUser> user in friendPickerController.selection)
{
NSLog(#"\nuser=%#\n", user);
fid = user.id;
fbUserName = user.name;
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:remedyLabel, #"caption", appIcon, #"picture",symptomName, #"name",remedyDescription,#"description",fid,#"tags",fid,#"to",#"106377336067638",#"place", nil];
NSLog(#"\nparams=%#\n", params);
[FBRequestConnection startWithGraphPath:[NSString stringWithFormat:#"%#/feed",fid] parameters:params HTTPMethod:#"POST" completionHandler:^(FBRequestConnection *connection,id result,NSError *error)
{
[FBWebDialogs presentFeedDialogModallyWithSession:nil parameters:params handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error)
{
if (error)
{
NSLog(#"Error publishing story.");
}
else
{
if (result == FBWebDialogResultDialogNotCompleted) {
// User clicked the "x" icon
NSLog(#"User canceled story publishing.");
}
else
{
// Handle the publish feed callback
//Tell the user that it worked.
NSLog(#"Request Sent");
}
}
}];
}];
}
}];
}
No, that's not possible. You have to open separate dialog for each friend.