Tagging a user in a wall post/update using Facebook API - facebook

I'm using stream.publish to write to the user's wall and attempted to get "# tagging" to work but with no avail.
If the user's name is Fred and his uid is 1234, I tried sending over "#Fred", "#1234", "#[1234]", "#[Fred]", etc. and couldn't get it to work. The raw string would display every time.
Can someone confirm if this is possible with the API or not? Thanks!

the correct syntax is
#[user_id:1:name]
it shows as a tag, but it doesn't trigger a notification. Anyone knows why?

Maybe you need follow this: NOTE: You cannot specify this field without also specifying a place.
You need to specify a place with the fan page ID of the location associated with the post.
more… https://developers.facebook.com/docs/reference/api/user/#posts

reese:
#[user_id:1:name] - It will replace it with the 'name' which you have given
#[user_id:0] - This will notify the user BUT it will happen when you MANUALLY typing it in wall or comment section NOT through graph api, say for eg., if you want to notify this user #[user_id:0] so you are appending this text in message parameter of https://graph.facebook.com/feed api it won't work, I hope you understand :)

Related

Get user that made the comment in facebooks instagram graph api

Im building an application that manages comments for instagram business profiles, and i'm a little surprised that there doesn't seem to be a way to get info of the user who made the comment.
The docs seem to point this way too:
Reading a Comment
To read an individual comment's metadata, send a GET request to the /{instagram_comment_id} node and include any of the following fields:
...
user (only returned if the user making the query also made the comment)
So, am i to understand that there is no way to get the info of a user which made a comment on a media of the profile i manage or is there something i am missing? any help would be appreciated.
Thanks in advance
This url worked for me:
v3.0/{comment_id}?fields=id,timestamp,username,text
somehow I was able to get the username from graph API, but I'm not getting the fields name, profile_picture_url, etc. this is my URL for getting the username.
GET https://graph.facebook.com/v2.11
/123?fields=mentioned_comment.comment_id(456){user{id, username}, text}
123 - instagram_business_account id
456 - comment id
You can get full user details from username by Calling Instagram API(Maybe it's against there privacy policy). suppose stackoverflow is the username, by calling this API you will get full data.
https://www.instagram.com/stackoverflow/?__a=1

Yammer REST API - Documented Parameter not working

The API documented here - http://developer.yammer.com/restapi/#rest-users clearly states:
"4) Alias to /api/v1/users/current user’s id.format. Supports include_followed_users, include_followed_tags, and include_group_memberships parameters.
GET https://www.yammer.com/api/v1/users/by_email.json?email=user#domain.com`
Yet, when we try this, it does not return any followed user information at all! The request we're using is like so:
https://www.yammer.com/api/v1/users/by_email.json?email=me#company.com&include_followed_users=true
However, this request DOES return followed users, but only for the current user:
https://www.yammer.com/api/v1/users/current.json?include_followed_users=true
Am I missing something completely obvious and being stupid or is there a real issue here? If this was taken out for whatever reason, then you'd have thought that the API documentation would have been updated.
The Yammer Team did eventually get back to me on this. Their response below:
(I've removed https://www.yammer.com from URLs because I don't have enough rep' to post more links)
Hey Jason Dunbar looks like the documentation here is wrong.
I looked in to this and had some conversations with a few engineers this week and have the following (albeit more arduous workaround):
1) Call get user by email endpoint and retrieve the id attribute from here: /api/v1/users/by_email.json?email=user…
2) To grab following users, take that id and:
GET /api/v1/users/following/[:id].json
3) To grab group memberships for that user you'll need to impersonate him/her (verified admin only) and
GET /api/v1/users/current.json
We'll get the documentation updated ASAP with this. Also happy to keep the conversation going to help if needed.
Make sure you are setting the email parameter to the user's email that they are registered with.
E.G. if your company has multiple domains but the Yammer network is under bigco.com and the user is registered with an email under bigcosubsidiary.com you'll need to make a request to the API with user#bigcosubsidiary.com.
-as mentioned - it looks like its only for current.json - you can check it here http://yammer-dev.herokuapp.com/endpoints/4 - hope it helps.
Rich

How to get name of Facebook user that left comment using FB.Event.subscribe

I'm trying to figure out how to get the name of the Facebook user that left a comment in the Comment Social plugin using FB.Event.subscribe and the comment.create event.
I only see 2 properties on the response object:
response.href: URL of the page that the comment was left on
response.commentID: ID of the comment thread
Is it possible to implement client side code to get the name of the facebook user that left the comment? I'm trying to save an extra roundtrip for my server to make a call the graph API to get all the comments then try to figure out who the user was that left the most recent one. I thought that there might be a way to run an FQL query, but I'm at a loss here.
I figured this would be an obvious thing for the facebook event to expose, but their documentation is so poor I haven't been able to see anything.
Update: I've tried using FB.api as suggested by another user and using /me but I can't use that since hte user leaving the comment hasn't granted me any permissions. This was confusing because they logged in to post the comment in the comment box AND the user's name is public info if you go to the user's facebook page. So I need a way to query the commenting user's name without using /me in FB.api.
This method definitely works to get a name.. but there is a race condition issue if it is a thread that is getting a ton of comments, as the request to get the comments might not get sent before another comment is made:
FB.Event.subscribe('comment.create', function(comment) {
FB.api('comments', {'ids': comment.href}, function(res) {
var data = res[comment.href].data;
console.log(data.pop().from.name);
});
});
This works without the user authenticating your app as well.
After reading TMC's comment below I realized that it is not possible without permissions. If you want to this then you will have to ask every commenter to grant you basic permissions.
ORIGINAL ANSWER
You can use Facebook Javascript SDK function FB.api which works the same way as PHP SDK's api function but returns a JSON string. Have a look at this page for documentation. You might also like to have a look at Comment Object Documentation.
Comment has a property from which gives the id and name of the user.

iPhone facebook integration

I am using Graph API in my application. I am fetching user's facebook wall feeds using graph API also getting details of particular post i.e (Like count,Comments etc).
but i want to allow user to Like and Comment any post from the application itself.
what is the request format for that?
Please help me or give any pointers.
Regards,
Sanket
You would be well served to check out the Publishing section of the documentation. It provides information such as this.
One example is liking, which is defined as:
Method: /OBJECT_ID/likes
Description: Like the given object (if it has a /likes connection)
Arguments: none
Basically, just initiate a Graph API call to something like:
[facebookObject requestWithGraphPath:#"98423808305/likes" andDelegate:self];
That will "like" a picture from Coca-Cola (ID taken from the documentation).
Edit 1
According to the documentation:
Most write operations require extended permissions for the active user. See the authentication guide for details on how you can request extended permissions from the user during the authentication step.
Are you sure you have enough privileges? Unfortunately the documentation is very unclear as to whether it serves the dual purpose of liking the object and returning the likes already on that object.
Edit 2
I did some more research into what could be causing this and came across this question and answer that indicated that the code I posted above using requestWithGraphPath:: should work. However, it does not due to a bug on Facebook's Bug Tracker.
Unfortunately, it looks like there is no way to "like" an object via the Graph API, which seems very strange to me. Perhaps it is possible with the legacy REST API instead of the Graph API?
Edit 3
Well, it looks like your best bet is the stream.addLike method of the legacy REST API which you can still call using the Facebook iOS SDK. You should be able to use the stream.addLike method to "like" something in the "stream". Unfortunately, it doesn't appear to support photos, videos, etc. Only posts and comments.
Finally i found the solution for LIKE option
We should use following method for like option.
-(void) requestWithGraphPath:(NSString *)graphPath
andParams:(NSMutableDictionary *)params
andHttpMethod:(NSString *)httpMethod
andDelegate:(id <FBRequestDelegate>)delegate
graphPath = /OBJECT_ID/likes
Paramas = dictionary with comment ,for like option use empty dictionary
HttpMethod should be POST
you should get response = true if the LIKE request is successful.

Stream.publish won't translate {*actor*} using Facebook Connect for iPhone

I am able to successfully publish a stream to my account using Stream.publish via Facebook Connect for iPhone. However, the {*actor*} token does not appear to get translated. I though this was a token that Facebook automatically translates to the user. Is this not the case? Here is my attachment JSON array.
attachment = "{"name":"Join {*actor*} PocketBracket Pool - The Pool Name
pool","href":"http://www.pocketbracket.com/pools/1741",
"media":[{"type":"image",
"src":"http://www.pocketbracket.com/library/images/icon_facebook_post.png","href":"http://www.pocketbracket.com"}],"description":"Get
ready for the 2010 Men's College Basketball Tournament! Fill out your own
bracket and challenge your friends with PocketBracket."}";
Otherwise, I am only setting message and action_links. Do I need to set uid? Again everything shows up correctly, but {*actor*} is still literally within my stream.
Thanks,
Jason
RTFM, Looks like actor can only go in the caption:
caption: A subtitle for the post that should describe why the user posted the item or the action the user took. This field can contain plain text only, as well as the {actor} token, which gets replaced by a link to the profile of the session user. The caption should fit on one line in a user's stream; make sure you account for the width of any thumbnail.
Please let me know if this is not correct.
You can use the tag {actor} only in caption, tested :)