what is target id in this code - iphone

what is target id is it application id or what. what should be its data type.
NSString *message = #"test message here";
NSMutableDictionary *params = [NSMutableDictionary dictionary];
[params setObject:message forKey:#"message"];
[params setObject:toID forKey:#"target_id"];
[[FBRequest requestWithDelegate:self] call:#"facebook.Stream.publish" params:params];
please answer soon....

Read the beginning of this post.

Its a key in params. from the looks of things (not for sure, since you provide basically no code or context of the code) it is a string that contains the ID to which you are sending your facebook request. Try looking in the API for the Library you are using.

Documented here: http://developers.facebook.com/docs/reference/rest/stream.publish
The ID of the user, Page, group, or
event where you are publishing the
content. If you specify a target_id,
the post appears on the Wall of the
target profile, Page, group, or event,
not on the Wall of the user who
published the post. This mimics the
action of posting on a friend's Wall
on Facebook itself.

Related

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

Facebook Graph api wall post not as link

Using the graph api I can post to a users wall:
[[NSMutableDictionary alloc] initWithObjectsAndKeys:
#"https://developers.facebook.com/ios", #"link",
#"http://www.xmaselves.co.uk/wp-content/uploads/2012/05/gym.png", #"picture",
[self getTitleText], #"name",
[self getCaptionText], #"caption",
[self getFbFormattedDescription], #"description",
_comment.text, #"message",
nil];
[FBRequestConnection
startWithGraphPath:#"me/feed"
parameters:postParams
HTTPMethod:#"POST" .... etc
The problem is this only seems to post on the wall as a link:
I want the post to appear as normal and not as a 'shared a link' post. How do achieve this with the graph api.
EDIT
Removing the link paramater and making sure #message is specified will indeed post to the wall.
If you remove the link paramater and do not specify message nothing is posted and no error is returned!
In the screenshot 'asdadasd' would be the user entered message but this is optional! So if they don't enter a message the post wont be displayed! As a matter of fact this same behaviour is exhibited by the 'Feed dialogue' api.
So all posts need to have a message? or posted as a link? This doesn't seem right.

Publish message to friend's wall from iPhone app

I would like my iPhone app to be able to post a static message to a user's friend's facebook wall. Something like it shows the static message up above, and then a place to type in friends name and shows suggested friends. Is this done through graph api, or is there a key of permissions that the POST method can use?
Looks like this might be what you are after.
From the link:
"You just have to send your friend's Facebook ID as a parameter under the key "target_id".
set a parameter under the key #"target_id" on the parameters dictionary (when invoking dialog:andParams:andDelegate: on the Facebook object).
Here you have a sample post using the new sdk (the one that uses graph api):
NSMutableDictionary* params = [NSMutableDictionary dictionary];
[params setObject:#"Some text" forKey:#"user_message_prompt"];
[params setObject:#"another text" forKey:#"action_links"];
[params setObject:#"Yet another text" forKey:#"attachment"];
[params setObject:#"SOME FACEBOOK ID" forKey:#"target_id"];
//At some point you need to create the following Facebook instance
[facebook dialog: #"stream.publish"
andParams: params
andDelegate: self];
you first need to request the friend list and then provide an interface in your app where user could select which friend's wall he want to write on... :)
afterwards, you can pass the selected friends id to the dialog you are presenting to the user... Atleast I am used to do it this way and it seems to be a pretty standard way of publishing something on user's wall...
hope it helps

Posting to message Facebook from iPhone/iPad

I have a 2-part question about posting messages to Facebook.
1 - I want to pre-populate the message that the user is going to post i.e. where it says 'Say something about this...'. Is this possible? If so, how? At the moment I have the following setup to produce the post shown below:
NSMutableDictionary *params =
[NSMutableDictionary dictionaryWithObjectsAndKeys:
#"Steak Expert", #"name",
#"The must-have iPhone/iPad app for carnivores!", #"caption",
#"Steak Expert helps you to cook every steak to perfection! With this app in your hand you'll never need to worry about over-cooking or under-cooking a steak again. Perfection every time! ", #"description",
#"https://m.facebook.com/apps/MY_APP_ID/", #"link",
#"http://fbrell.com/f8.jpg", #"picture",
#"Cooking a steak using Steak Expert!", #"message", // I thought this would be the required field to populate the text
nil];
[facebook dialog:#"feed" andParams:params andDelegate:nil];
2 - The other part of my question is based around the view shown above. Is it possible to automatically post to the wall without the need for this view to appear? Seeing as the user must authorise the app to even connect with Facebook (plus any other specified actions) I can't see it being an issue. If so please could someone advise on how to achieve this?
It is the message field that you are talking about.
message - This field will be ignored on July 12, 2011 The message to prefill the text field that the user will type in. To be compliant with Facebook Platform Policies, your application may only set this field if the user manually generated the content earlier in the workflow. Most applications should not set this.
http://developers.facebook.com/docs/reference/dialogs/feed/
Hope this helps
As #Illep stated, the message field no longer works for the dialog postings.
To answer your second question, you can use the graph API to straight post to a user's wall without showing the dialog box. Take a look at the documentation here. You would use the following code to write the message:
// Set parameters
NSMutableDictionary *params = [NSMutableDictionary dictionary];
[params setObject:FACEBOOK_ACCESS_TOKEN forKey:#"access_token"];
[params setObject:#"Some preset message" forKey:#"message"];
// Make the request to the graph API
[_facebook requestWithGraphPath:#"me/feed" andParams:params andHttpMethod:#"POST" andDelegate:self];

how to post a photo and message to Facebook using the new Facebook GRAPH API on iPhone

I know how to post an image using the GRAPH API and I know how to post a comment using the same. But I can't figure out how to post a photo and allow the user to also include a message/status with the photo (all posting on the user's own wall).
This is the code that I am using to upload a photo from my app to user's wall. The GRAPH API does not define what other keys I can specify in the param dictionary.
-(void) uploadPhotoToFacebook {
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
imageView.image, #"picture", nil];
[facebook requestWithGraphPath:#"me/photos"
andParams:params
andHttpMethod:#"POST"
andDelegate:self];
}
I have found ways to do this using the now deprecated Facebook API but that doesn't help me.
Thanks for the help,
// Post a status update along with picture via the Graph API, and display an alert view
with the results or an error.
NSString *message = #"This is status Message!";
UIImage *image = [UIImage imageNamed:#"myPngImageToPost"];
NSDictionary *params = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:message, UIImagePNGRepresentation(image), nil] forKeys:[NSArray arrayWithObjects:#"message", #"picture", nil]];
// use the "startWith" helper static on FBRequest to both create and start a request, with
// a specified completion handler.
[FBRequest startWithGraphPath:#"me/photos"
parameters:params
HTTPMethod:#"POST"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
[self showAlert:message result:result error:error];
}];
The above code will show status update as well as image below your status message.
The documentation is here: http://developers.facebook.com/docs/reference/api/photo/ ... along with the restrictions and required permissions. I have been wrestling with it for a few days since not everything I expect to work works! For posting you want to use the "source" key instead of picture which refers to the thumbnail.
Posting on the wall (feed dialog) and comments (graph photo/comment) (comments and tags are adding connections) are all separate transactions. For posting, I'm struggling with it since I can post a photo by providing an existing URL from another website but for some reason, I cannot point use the photo link from the picture I just posted (the feed dialog appears without any photo).