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.
Related
Say you have a facebook page like:
http://www.facebook.com/example.name.1
How can I programmatically get the friend list of this page via get request.
If I can test this using the facebook console it would be very helpful.
Here is the code to get your friends list. So, you can start from studying the following code.
$friends = $facebook->api("/me/friends")
Or you can also use the sql to retrieve the friends list.
$friends = $facebook->api(array(
"method" => "fql.query",
"query" => "SELECT uid,name FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())"
));
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.
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'
i wrote a small FQL script that returns the latest wallposts of my fanpage. The script works fine. Until today.
The situation:
I published a wallpost with custom settings: The post is only visible to German fans.
The Problem:
My fql query ignores this "special" post.
My little PHP program looks like this
$query = " SELECT
post_id, message, created_time, attachment,action_links, privacy, type
FROM
stream
WHERE
source_id = ".$page_id."
AND actor_id = ".$page_id."
ORDER BY created_time DESC";
$param = array(
'method' => 'fql.query',
'query' => $query,
'callback' => ''
);
$result = $this->facebook->opengraph->api($param);
The nugget:
Facebook returns the status message if i call the special post like this:
https://graph.facebook.com/367501354973
(Source: http://developers.facebook.com/docs/ref … api/status)
Thanks for helping
In general, content which is demographically targeted or restricted will only be made available to a user access token for a user who meets the demographic set - check that the user you're trying to access the posts as is actually in the demographic you targeted the post at.
I got a similar problem using the grpah api:
This does NOT return the special post
https://graph.facebook.com/MYPAGE/posts?access_token=SOME_TOKEN
If I call the graph via FB-Docs (they offer a special access token, i get the special post
https://graph.facebook.com/MYPAGE/posts?access_token=22223423470867|2.qnqX1HsEaIXVr0lVHCRxiw__.3600.12913423423400-10043534534530485|4wqk8YYWXQ8bjfQj8KETz2JyWQk
Stange...
If your FQL is calling without an access_token, then the API won't return any posts that any kind of restrictions placed on them. In your example, geo gated to Germany.
The reason it's working via the Docs is that we're appending an access_token.