I need to work out if a user has my app installed so I can display a slighlty different page. How do you do this?
Ideally you'd want to capture their Facebook user ID in your own database when they originally install your app. When they come back, you can compare the current users Facebook user ID with your database to see if you find any matches.
If you don't have a database, you can always check on a user permissions using the Graph API. You can find the code here: http://developers.facebook.com/blog/post/495
This will give you back an array that looks something like this:
Array ( [data] => Array ( [0] => Array ( [installed] => 1 [bookmarked] => 1 ) ) )
In this case, the user has it installed and has bookmarked it. Now that you know that, you can display a slightly different page.
You do this by using the FB JavaScript API and querying if the user is logged in. If it is (to you) it will have your app installed.
Related
I want to get all facebook group post using FB Graph API.
I searched , googled, seen documentation for graph api, asked to so many persons, all are saying it is possible
Also i'm providing link from stackoverflow which i referred and tried
How to get all posts of a group via facebook graph api
But as you can see the post is very much old (from 2013)
When i tried to send request using CURL, at that time i'm not getting any error not any data
When i tried below code
$publish = $facebook-api('https://graph.facebook.com/v2.3/'.$group_id.'/feed/?access_token='.$params['access_token']);
at least i'm getting something in response
Array
(
[og_object] => Array
(
[id] => 859455820800214
[type] => website
[updated_time] => 2015-06-04T12:18:15+0000
[url] => https://graph.facebook.com/v2.3/659988617465253/feed/
)
[share] => Array
(
[comment_count] => 0
[share_count] => 0
)
[id] => https://graph.facebook.com/v2.3/659988617465253/feed/
)
So i just wanted to know that is it really possible at this moment?
And one good thing is that when i'm trying it from Graph API Explorer, i'm getting the data properly.
So where i'm wrong ?
Any little help would be greatly accepted
Why don't you just use the Facebook PHP SDK?
https://developers.facebook.com/docs/reference/php/4.0.0
You can get the group's feed via /{group_id}/feed, as described at
https://developers.facebook.com/docs/graph-api/reference/v2.3/group/feed#read
Make sure your Access Token is of the right type and contains the right permissions.
I am using the Graph API to retrieve Feed data from a number of public Facebook pages and a public Facebook group. The array of data returned by the API occasionally contains Posts with missing data which is visible when the Posts are viewed in Facebook.
I wonder if anyone can shed light on this, and explain whether it is just a glitch in the Graph API, or some sort of permissions issue?
The problem appears to occur with data from the public Facebook Group, and affects Posts which are of [type]=Status under certain conditions. A couple of examples:
Posts of [type]=Status where the user has included a link: In this scenario, the Post [message] is present, but the [link] and [picture] elements are missing. The data returned includes the following data - "[caption] => Attachment UnavailableThis attachment may have been removed or the person who shared it may not have permission to share it with you".
All the [comments] and [likes] data is present and correct.
Posts of [type]=Status where the user has posted a photo: In this scenario, the [message] and [picture] elements are missing, but the [comments] and [likes] data is present.
For Posts of [type]=Status with just a simple [message] (no photo or link) the Post data all seems to be returned correctly by the API. Posts of [type]=Link or [type]=Photo are also returned correctly. I don't seem to see any of these problems when retrieving data from the Facebook Pages.
I am using the Facebook PHP SDK to retrieve the data. Currently I am using SDK 4, but I experienced the same problem with the previous version of the PHP SDK. I am making a simple GET call, with an App Session constructed using my App ID and App Secret (no access token).
I'm guessing there is something subtle going on with permissions here (as indicated by the caption message for the first scenario above) but the Group is public, and the missing data can be viewed on the Group page by any Facebook user.
This question appears to be related but I have not been able to track down any information about my specific problems, so any suggestions gratefully received!
I found a whole bunch of related questions here, but since Twitter had made a lot of changes in its API, most of them are outdated (+ nothing actually solved my problem).
So My website is a semi social network (with posts, likes comments etc). The user has the option to post to twitter and facebook through my site. Everything is working just fine, posts are finding their way to both FB and TW.
I'm using Twitter oauth php library, posting is done like so:
$response = $connection->post("statuses/update", array('status' => "Tweet"));
but when if I want to verify user's credentials like so:
$response = $connection->get("account/verify_credentials.json");
I get:
[0] => stdClass Object
(
[message] => Sorry, that page does not exist
[code] => 34
)
I don't think the problem is in the authentication process nor in the app settings, for I was able to post a tweet but got that same error, both using the same access token (and obviously the same app).
apparently you get this 34 error for a variety of cases, the documentations is so ambiguous about it.
So any troubleshooting techniques are appreciated.
Just use
$response = $connection->get("account/verify_credentials"); // Remove the .json
I'm trying to get the status from facebook users, who connect to my app with offline_access and read_stream permissions.
All the processes will use subscription to get notification about new feeds, and then take access to status of the user, who changed it.
The code for subscription works great, I get all info as it should be, but the problem starts with second part - every time I try to access user status via
$objFacebook->api('/'USER_ID'/statuses?access_token=TOKEN', 'get', $params);
I get the exception:
An access token is required to request this resource
I tried to set access_token which I got when connected to my website via facebook login, also tried to set the whole session in similar way as it is done here:
Array
(
[access_token] => ...
[base_domain] => ...
[expires] => 0
[secret] => ...
[session_key] => ...
[sig] => ...
[uid] => ...
)
but it didn't help. On the other side, when I copied my access_token generated via facebook developers (http://developers.facebook.com/docs/reference/api/user/) it works correctly, so it looks like my app generates an incorrect access token.
Do you have any idea where the problem can be?
To connect I use facebook-php-2.0 library.
You should upgrade to version 3 of the PHP SDK. We made some changes to the cookie format and other things you can read about here. Version 2 will stop working on September 1st, so you'll need to upgrade soon anyways. Once you've done that, things should work for you.
P.S. You probably will want to use the "/posts" connection rather than than the "/statuses" connection of the User object as it will also give you any posts the user made that include attachments. The "/statuses" connection will only return text-only posts the user made. We'll update the documentation to clarify that.
I would like my canvas application to obtain time-zones of my user's friends.
I tried doing it with the Graph API but all I can get is their names, locales and a few more (even when using the access_token).
When using FQL the timezone field is always empty.
Is there a way to achieve this?
If so, could you please point me in the right direction?
Cheers
I guess this is not possible, only the following fields were retrieved when calling $this->facebook->api("/friend_ID");:
Array
(
[id] =>
[name] =>
[first_name] =>
[last_name] =>
[link] =>
[gender] =>
[locale] =>
[updated_time] =>
)
Now in the documentation, the above fields are the fields marked Publicly available, in time the timezone field is Available to everyone on Facebook which sounds like the same but apparently it's not, anyway I've found this interesting article for a moderator on the facebook forums (not a developer!!)
Also tried the old rest lib, first get a list of your friends from the console and then add your ID and put them in the test console of the users.getinfo method, UIDs looks like your_id,friend_id,friend_id,friend_id,friend_id and fields timezone you'll only get your timezone.