Basically I got 2 question here:
once the user given permission to a facebook application at fbconnect, is it anytime the application can post the fb user's wall?
How about later when they logout from facebook already?
Does application owner still have the permission to like post to their wall? Or need to wait till they login to facebook connect the second time only can re-access the information?
Somehow the birthday field for all my friends are returning as empty.
I am using latest php sdk from github.
$friends = $facebook->api('/me/friends');
$_SESSION['fb_user_friends'] = $friends;
foreach ($friends as $key=>$value)
{
echo '<br>';
foreach ($value as $fkey=>$fvalue)
{
//all the query return values, except birthday and birthday_date field
//birthday and birthday_date field totally don't have any friend's DOB appearing, all empty.
//wonder why
$fql = "SELECT uid, first_name, last_name, name, birthday, birthday_date FROM user WHERE uid=".$fvalue[id];
$param = array(
'method' => 'fql.query',
'query' => $fql,
'callback' => ''
);
$userDetails = $facebook->api($param);
print_r($userDetails);
}
}
EDIT: this is no longer an accurate answer
-It can post on the wall if you asked for that permission.
'req_perms' => 'publish_stream,...
To post on wall of loged out user you need another permission "offline_access". All permissions: http://developers.facebook.com/docs/authentication/permissions
-Birthday. I experienced the same. Birthday sometimes empty because user didn't provided it or set the security high and apps can't ask for it. And you have to ask for 'friends_birthday' permission too at registering to your app.
in 'settings' on your application, go to 'permissions' and enable 'User & Friend Permissions': 'user_birthday', 'friends_birthday'
Related
I've adapted Facebook's example code to let me show the list of invited users... but I can't get a list.
Can someone help me with the right syntax to get a list of invited friend?
This is what i've come with so far:
$invite = $facebook->api('friends.invite');
$result = $facebook->api('/me/friends/','invite');
Or i try to connect FQL
$_friends = $facebook->api(array(
'method' => 'fql.query',
'query' => 'SELECT sender_uid FROM apprequest WHERE request_id = $id'
));
I can confirm that BEFORE this point in my code,
things were fine: I'm connected to Facebook with a valid session
and I can get my info and dump it.
Previously, I was checking if user has liked the facebook app or not using the following code:
$fql= "SELECT uid FROM page_fan WHERE page_id = '$appid' and uid='".$me['id']."'";
$param=array(
'method' => 'fql.query',
'query' => $fql,
'access_token' => $access_token
);
$fqlResult1 = $facebook->api($param);
$hasliked = count($fqlResult1);
But now this code doesn't work anymore. Is there any solution to this problem?
Facebook has blocked the feature that we can check whether facebook apps are blocked or not from about 6,8 months.
You could use:
$facebook->api("/$user/likes");
It provides list of likes for the user. If you application is in the list then its liked by the user else not.
Did you mean something like that.
you can check by specifying your page id while giving api call like this
https://graph.facebook.com/me/Likes/" + pageId/appId + "?access_token=" + oAuthToken
if response contains data it means your page/app is liked otherwise not.
I'm trying to retrieve all facebook events that a page that I have created, has been invited to. I created an App and following is the code I got from http://www.codeofaninja.com/2011/07/display-facebook-events-to-your-website.html:
//requiring FB PHP SDK
require 'fb-sdk/src/facebook.php';
//initializing keys
$facebook = new Facebook(array(
'appId' => '[app_id>],
'secret' => '[app_secret]',
'cookie' => true, // enable optional cookie support
));
$fql = "SELECT name, pic, start_time, end_time, location, description
FROM event WHERE eid IN ( SELECT eid FROM event_member WHERE uid = 100001660923071 )
ORDER BY start_time asc";
$param = array(
'method' => 'fql.query',
'query' => $fql,
'callback' => ''
);
$fqlResult = $facebook->api($param);
print_r($fqlResult);
Now the problem is that it works fine when the uid in the query is set to '221167777906963'(its the UID from the example code and it works wine with any app-id/secret combination) but when I set it to the uid of the page I am the owner of none of the events get returned. Is there something I'm missing? I double checked on my pages>accounts settings>apps to see if the app that I created had permission to the page and it does. Its a public page. What am I missing in the flow to give this app permission to get access to my pages events? The same query works fine if i run it in the Graph API Explorer with an access token that I generate for user_events.
I'm basically trying to understand why a particular Wordpress Plugin called FB Sync Events isn't working and the app authentication is what seems to be failing cuz the $facebook->api is returning nothing for a fql.query JUST for my page. QQ
For accessing the page's events, you might need to use a PAGE access token. Page access tokens are easy to get. For the page administrator's user access token, call Graph /me/accounts and in there will by the page along with an access token for that page. That is what is called a "Page Access Token". Then using that Page access token, call your FQL statement.
As far as I know it's no possible to display the events you have been invited to if you create a Facebook page instead of a profile. Since when you create a page you only have users who like you page. This means they can interact with the content you publish but they can't interact with you as a brand or company.
On the other hand when you create a profile you have users who are your friends and they can interact with you and the content you publish in many ways, including being able to be invited to events.
I have an app in which I want to check my users' online presence. Right now, when I check, it tells me everyone is offline.
The users grant user_online_presence and offline_access (plus a few other) permissions to the app. Then I store the access token. I am able to access any information I need at any time except for the online presence.
To get the online presence, I first set the access token:
$facebook->setAccessToken($user['AccessToken']);
Then I query Facebook:
$fql = "SELECT uid, name, online_presence, status FROM user WHERE uid = ".$user['FacebookID'];
$param = array('method' => 'fql.query', 'query' => $fql, 'callback' => '');
$fqlResult = $facebook->api($param);
When I check the results, I get the id, name, and status, but everyone is listed as offline, even me when I know I'm online and active:
[online_presence] => offline
Any help getting this working would be greatly appreciated. Thank you all for your time.
I used this FQL query sucessfully :-
SELECT name,online_presence FROM user WHERE uid
IN (SELECT uid2 FROM friend WHERE uid1 = me())
to get all the online friends. Got output as "idle","active" and "offline". All values of which were absolutely correct.
There are 2 permits
user_online_presence, for the user
friends_online_presence, for friends
http://developers.facebook.com/docs/reference/api/permissions/
online_presence is for chat online, not facebook online
The user's Facebook Chat status. Returns a string, one of active,
idle, offline, or error (when Facebook can't determine presence
information on the server side). The query does not return the user's
Facebook Chat status when that information is restricted for privacy
reasons.
Also, I ran fql?q=SELECT name, online_presence FROM user where uid IN (Select uid1 from friend WHERE uid2=me()) and it listed my friend's online status fairly accurately. Only a very few were incorrect. Maybe that's due to a lag in the facebook update system, or maybe they're caching the information for too long, etc.
I will give a fan page link to any user in a facebook application, and tell that user to do like that page.
so how can I check that the specified user has clicked on like, I to check this by a script/FBML.
I want a script that returns true/false if I give a parameter of that page.
or I want to get pages list of that user so I can search that I want in that list.
How can I do this or is there any fbml which can extract pages list of current loggedin user.
Looking forward for your kind reply ans sorry for my english.
Thanks in advance...
Regards,
Muhammad Hanif
Well I'm not sure what you are asking, but I'll try my best answering your "questions".
I want a script that returns
true/false if I give a parameter of
that page.
So you already have the user id and the page id, you can check if the user is fan in two ways:
pages.isFan:
$isFan = $facebook->api(array(
"method" => "pages.isFan",
"page_id" => $page_id,
"uid" => $user_id
));
if($isFan === TRUE)
echo "I'm a fan!";
FQL:
$result = $facebook->api(array(
"method" => "fql.query",
"query" => "SELECT uid FROM page_fan WHERE uid=$user_id AND page_id=$page_id"
));
if(count($result))
echo "$user_id is a fan!";
Source: Facebook API: Check If A User Is Fan Of A Facebook Page.
You can also capture when the user "Like"s something, for this check Tracking Facebook “Like” Referrals.