How do I post on friends' walls? - iphone

I am using the following code to post on device user's wall. I have managed to get the friends list and their ids too. Using the friend's id how can I use the following code to post on selected friend's wall depending on friend's id?
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook ];
SLComposeViewControllerCompletionHandler myBlock = ^(SLComposeViewControllerResult result) {
if (result == SLComposeViewControllerResultCancelled) {
NSLog(#"Cancelled");
} else {
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:#"Posted!!!"
message:#"your status is posted to facebook successfully" delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
}
[controller dismissViewControllerAnimated:YES completion:Nil];
};
controller.completionHandler =myBlock;
[controller setInitialText:#" hello there you got a text ..."];
[self presentViewController:controller animated:YES completion:Nil];
}

Take a look at the question Anton pointed you to. However, to my understanding, Facebook will be removing the ability to post to a friends wall using the Graph API in February 2013. Instead you will need to create a post by invoking the Feed Dialog and tagging friends in the post. The post will then appear on their wall (assuming they approve it). You'll want to keep this in mind as you decide how to go about this.

Posting to other users wall is as of February 6, 2013, deprecated.
https://developers.facebook.com/roadmap/completed-changes/
Removing ability to post to friends walls via Graph API
We will remove the ability to post to a user's friends' walls via the Graph API. Specifically, posts against [user_id]/feed where [user_id] is different from the session user, or stream.publish calls where the target_id user is different from the session user, will fail. If you want to allow people to post to their friends' timelines, invoke the feed dialog. Stories that include friends via user mentions tagging or action tagging will show up on the friend’s timeline (assuming the friend approves the tag). For more info, see this blog post.

You can't post to friend's wall from API, But can be published to their Stream

Related

iOS: Incorrect/Repetitive Facebook Request Message

I'm using the Facebook SDK and Parse.
I am submitting additional requests for the users email, events, and their friends' events.
Although I receive this info successfully, users who are logged into iOS' facebook system get this popup when I request permissions.
Notice that they are already logged into facebook (via the settings app) and they are simply getting a message to approve the request.
As you can see, it repeats the info about basic profile and friend list (FB login gives you this by default) and doesn't even mention the email. Since I doubt Apple or FB has made this kind of mistake, I assume it has something to do with me. Here is how I request access using FB and Parse.
// The permissions requested from the user
NSArray *permissionsArray = #[ #"email, user_events, friends_events"];
// Login PFUser using Facebook
[PFFacebookUtils logInWithPermissions:permissionsArray block:^(PFUser *user, NSError *error) {
[activityIndicator stopAnimating]; // Hide loading indicator
if (!user) {
if (!error) {
NSLog(#"Uh oh. The user cancelled the Facebook login.");
} else {
NSLog(#"Uh oh. An error occurred: %#", error);
}
} else if (user.isNew) {
NSLog(#"User with facebook signed up and logged in!");
[self.delegate ViewWasDismissed];
[self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
} else {
NSLog(#"User with facebook logged in!");
[self.delegate ViewWasDismissed];
[self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
}
}];
again, this request WORKS. Therefore, I can't imagine what I could be doing wrong, but the message is strange. Any ideas?
EDIT: I tried deleting my account from the iOS facebook system and requesting directly through the app. This time I got this message:
Notice that here, the user is logged into facebook via the FB app and simply gets this (correct) message to accept permissions.
Is this some kindof bug with Apple's Facebook system?
This is the correct behaviour that will happened for iOS. Since iOS 6, Apple has integrated Facebook to the devices. Therefore, users can log in Facebook from Settings page. Below are the scenario that explain your confusions.
Scenario 1: Logged in to Facebook from Settings page
The app will automatically detect the Facebook account from your device if there's any, and prompt you the permissions request with UIAlertView. This only happen if you're using latest SDK and I am not so sure since which SDK that Facebook released for iOS has this.
Scenario 2: Not logged in to Facebook from Settings page (Old way)
The app will lead you to Facebook app if it's installed in your device. Else it will lead you to Safari with Facebook mobile page open and ask you for permissions that the app required.
Hope this help :)

Facebook permissions required to tag a friend in a wall post..?

I want to tag a friend in a post which I am posting on my wall , just wanted to know what permissions are required...?
I am using the following code...
For permissions..
NSArray *permissions = [[NSArray alloc] initWithObjects:
#"friends_online_presence",
#"read_stream",
#"email",
#"publish_stream",
nil];
[self.appDelegate.facebook authorize:permissions];
[permissions release];
and to post
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"Test 2",#"message",
#"100004311843201,1039844409", #"to",
nil];
[self.appDelegate.facebook requestWithGraphPath:#"me/feed" andParams:params andHttpMethod:#"POST" andDelegate:self];
This gets posted on wall successfully but the profile ids are not included...
Though its in PHP here is bug report which says it is problem in Graph API while posting status update and tagging friends is not working properly.
It says that it will post status update but tagging is not working.
EDIT:
As discussed with OP in comments, adding place field attached to parameters it is working.
I think this should help you:
To mention a user in a user message, place this string inline with the message: #[userID] or #[profileUrl]. This creates an inline hyperlink to the profile of the mentioned friends and sends them a notification that they have been tagged.
Taken from: https://developers.facebook.com/docs/technical-guides/opengraph/mention-tagging/
For tag friends in Facebook friends id are required to tag in post etc.
customer friend picker is better for tag friends.
see below Facebook sample
https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-xpa1/t39.2178-6/851564_497226807066458_2037734970_n.png
for this purpose us this graph api taggable_friends to get tag able friends
for more detail visit this link and read tag section (Mention Tagging is suite for your requirements)
mentiontagging detail info

How to implement twitter login functionality on iPhone

I've already tried to use Facebook login functionality. During the login I got user token and using this token I could identify user. So, Facebook is OK for me.
1) How can I implement login functionality with Twitter? Will I get anything the same like user token on Facebook?
As far as I know, to use twitter API user should be login in twitter in the settings of iPhone. Can I implement anything to enable user to login even he is not yet logged in in the settings of iPhone?
2) After user login I want him to invite his twitter friends to my application. Is it possible to do? And in what ways?
I will be grateful for some code examples.
Please check the link below each and every step is clearly told by Twitter itself.
https://dev.twitter.com/docs/ios
If you still having problem please follow the link
http://www.raywenderlich.com/5519/beginning-twitter-in-ios-5
That contains the code and all steps !
Hope it will help you !
Please go through this link
it will provide stepwise details.
add
#import <Twitter/Twitter.h>
Then you can tweet something using:
-(IBAction)tweetTapped:(id)sender {
{
if ([TWTweetComposeViewController canSendTweet])
{
TWTweetComposeViewController *tweetSheet =
[[TWTweetComposeViewController alloc] init];
[tweetSheet setInitialText:
#"Tweeting from iOS 5 By Tutorials! :)"];
[self presentModalViewController:tweetSheet animated:YES];
}
else
{
UIAlertView *alertView = [[UIAlertView alloc]
initWithTitle:#"Sorry"
message:#"You can't send a tweet right now, make sure
your device has an internet connection and you have
at least one Twitter account setup"
delegate:self
cancelButtonTitle:#"OK"
otherButtonTitles:nil];
[alertView show];
}
}

How to give extended permissions in FBConnect with REST API in iPhone

I have developed an iPhone application, which is communicating data with faceBook. Initially I was only able to get basic information of user from Facebook. To post to a user's wall, I learnt about giving extended permission 'publish_stream', hence I added following code snippet:
- (void)session:(FBSession*)session didLogin:(FBUID)uid {
FBPermissionDialog* dialog = [[[FBPermissionDialog alloc] init] autorelease];
dialog.delegate = self;
dialog.permission = #"status_update";
[dialog show];
[self getFacebookName];
}
And made necessary changes in the FBPermissiondialog class file.
Now this is allowing me to post to my wall, but it shows two separate dialogs for permissions, first to access user's basic information, and second for publishing permission. I want to have all permissions in a single pop-up. Also, I am using FBRequest to post to Facebook, not FBStreamDialog (as I dont want the UI for posting).
Please help me with this, I badly need to resolve this issue soon.
Thanks in advance.
In FBLoginDialog.m file
- (void)loadLoginPage {
NSDictionary* params = [NSDictionary dictionaryWithObjectsAndKeys:
#"1", #"fbconnect", #"touch", #"connect_display", _session.apiKey, #"api_key",
#"fbconnect://success", #"next",#"user_photos,photo_upload",#"req_perms",nil];
[self loadURL:kLoginURL method:#"GET" get:params post:nil];
}
add "req_perms" key to the dictionary as shown above.
Hope this will solve your problem :)

How will this code publish an image to a wall using Facebook Connect?

I would like to know what this code does exactly.
- (void)dialogDidSucceed:(FBDialog*)dialog {
//[self doSomethingExciting];
FBStreamDialog *dialog2 = [[[FBStreamDialog alloc] init] autorelease]; dialog.delegate = self;
dialog2.userMessagePrompt = #"Example prompt";
dialog2.attachment = #"{\"name\":\"Facebook iPhone SDK\","
"\"href\":\"http://developers.facebook.com/connect.php?tab=iphone\","
"\"caption\":\"Caption\",\"description\":\"Description\","
"\"media\":[{\"type\":\"image\","
"\"src\":\"http://img40.yfrog.com/img40/5914/iphoneconnectbtn.jpg\","
"\"href\":\"http://developers.facebook.com/connect.php?tab=iphone/\"}],"
"\"properties\":{\"another link\":{\"text\":\"Facebook home page\",\"href\":\"http://www.facebook.com\"}}}";
// replace this with a friend's UID
// dialog.targetId = #"999999";
[dialog2 show];
}
When I run it it asks me if I want to publish on my and my friends walls, but Im not sure how this will look on the walls. Also does it publish to the users walls and then show up in their friends incoming stream, like "most recent" or does it actually post on every friends wall?
Thanks
Yes. You are posting an image to their stream.
Attachment is an escaped sequence of JSON that Facebook will pick up on and attach an image (and it looks like a link as well).
What the user will see is the image/link preconfigured as a wall post, and they will have a text box to enter their own text referred so as User Message Prompt.
Whether or not it shows up on friends streams depends on their settings, but ultimately, this is a news stream post, and thus has the potential to appear on their home page.
An other answer already explained what the code does.
This is just a tip:
Create three fake FaceBook accounts, and connect them together.
Then use them to do your testings. So you will know exactly what happens, and do all the tests you need during development without loosing all your friends.