CakePHP and Facebook Plugin: read user checkins - facebook

I am using CakePHP and Nick Baker's Facebook Plugin, and I am trying to retrieve a certain user's checkins. The problem is that I have quite no idea on how to do this. There is nothing related to checkins in the plugin's documentation. All I have is the api() method which I don't know how to use.
I have this so far:
App::import('Lib', 'Facebook.FB');
$FB = new FB();
$this->set('checkins', $FB->api('https://graph.facebook.com/'.$this->Connect->user('id').'/checkins'));
but the checkins variable contains only this:
Array
(
[id] => https://graph.facebook.com/1000005215732xx/checkins
)
But have no idea on how to continue. Also, after I retrieve the checkins, I would like to search whether a user has checked in in a specified place.
I will be glad for any help you can give! Thank you!

The api() method only takes a URL relative to the API endpoint, so you should be calling:
$result = $FB->api('/<uid>/checkins');
Also, make sure you have the proper permissions, especially user_checkins.

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

Facebook Applinks return no applink data at all

I'm using the Facebook Graph API, Mobile hosting API to post a link with the following:
https://graph.facebook.com/{APPID}/app_link_hosts?access_token={ACCESS_TOKEN}&name=Puzzle_1420352145684&ios=[{"url":"MyAPP://playerPuzzles/1420352145684","app_store_id":{MYAPPID},"app_name":"MyAPP"}]&web={"should_fallback":false}
I get the correct result in the form of the ID of the link, with no error.
But when I query the link with
https://graph.facebook.com?ids={LINK}&access_token={ACCESS_TOKEN};
I don't get any app-link data the object is there but empty not even the name.
{"http://fb.me/777314042342441" = {
id = "http://fb.me/777314042342441";
};
}
Is there something wrong in my posting that doesn't allow the data to get posted?
Thanks for you help in advance.
It seems that the facebook documenatation is wrong. I finally found a solution using the graph explorer.
To correctly fetch the data use this style of URL.
https://graph.facebook.com/{APP-LINK-ID}?fields=ios,name,web&access_token={ACCESS_TOKEN};
Please note that you have to call out all the fields you want. The object at least for me didn't include the app_links structure like the documentation.
Here is the link to the wrong Index API
Here is the app_links object structure you can see all the fields you can fetch.
Hope this helps everyone.

Does HWIOAuthBundle support retrieving friends list, gender, country

I have just implemented the HWIOAuthBundle in my symfony project. Actually, it is configured with facebook and I am wondering if it supports retrieving friends list, gender and country?
If yes, could you please provide me an example of code for the function public function loadUserByOAuthUserResponse(UserResponseInterface $response)?
It would be really helpful.
Thanks.
I found the solution by my self!!!
HWIOAuthBundle supports retrieving any thing you want. All what you have to do is to specify it in the facebook api then through the method getResponse() you will have access to them.
$attr=$response->getResponse();
// then get your field like this
$user->setGender($attr['gender']);
I guess now it is easy.

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.

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

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 :)