Using FQL in facebbok api php 4

Asked

Viewed 422 times

0

Staff need to run a simple FQL using Facebook SDK PHP 4 using the following command:

$result=(new FacebookRequest( $session, 'GET', $fql))->execute()->getGraphObject()->asArray()

and it generates me the following error:

Fatal error: Uncaught Exception 'Facebook Facebookauthorizationexception' with message '(#12) fql is deprecated for versions v2.1 and Higher'

I read that this kind of command is really outdated, but I couldn’t find anything to replace it.

As it is now in this new API 2.x?


I have this code I found.

$fql="/fql?q=SELECT uid, name,pic_square, birthday_date FROM user WHERE (substr(birthday_date, 0, 2) = '07') AND uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) order by name&access_token=".$_SESSION["token"];
$session = $this->login();
$result=(new FacebookRequest( $session, 'GET', $fql))->execute()->getGraphObject()->asArray();

How would I use it in the new API.

  • João, we are in the same boat. Some FQL features have no direct counterpart in the Graph API (e. g., see this my question). Unfortunately, with the date of April 30th knocking on the door, we either migrate for good or we migrate for bad. I recommend that you take a look at Graph API services and try to replace your FQL commands in the best possible way.

  • I really need to list the day’s birthday so I can send him a message. I just saw how to do this using FQL. Do you know somehow for this? Thank you

  • I do not know exactly what is your use case (if you want to post your FQL and expected return), however, I know with permission user_birthday you can consult a user’s birthday with the call: {id_do_usuario}?fields=birthday. For more information see: https://developers.facebook.com/docs/graph-apice/v2.2/user

  • So what I need is to develop a PHP site that accesses my facebook page and takes all the friendly menus that are birthday on the day and sends a generic message to them. I’ve already managed to list all the friends, now I have to find out which ones have a birthday and how to send a message to them. If you can help me Graduate.

  • Pole one mvce showing your problem. So you get more specific and targeted help.

  • I have this code I found. $fql="/fql? q=SELECT uid, name,pic_square, birthday_date FROM user WHERE (substr(birthday_date, 0, 2) = '07') AND uid IN (SELECT uid2 FROM Friend WHERE uid1 = me()) order by name&access_token=". $_SESSION["token"]; $Session = $this->login(); $result=(new Facebookrequest( $Session, 'GET', $fql))->execute()->getGraphObject()->asArray(); .

Show 1 more comment

1 answer

0


You can get birthday friends with the following consultation:

$request = new FacebookRequest(
  $session,
  'GET',
  '/me/friends?fields=friends{id,name,birthday}'
);
$response = $request->execute();
$graphObject = $response->getGraphObject();

For that you need the authorization user_friends.

Note that since version 2.0 of the API this call will only return user friends who also use your application.

Unfortunately, to the best of my knowledge, there is no way to filter the anniversary date directly from the call, you will need to iterate the response elements and filter client-side dates.

  • Anthony I did as you said and I got this: Array ( [data] => Array ( ) [Summary] => stdClass Object ( [total_count] => 124 ) )

  • You can test on Graph API Explorer, probably or you did not request permission user_friends or has no friend using the application.

  • The permission I have but my friends do not use this my app. This application I am developing is only for me. Like I’d make them wear?

  • They would have to log in to the app page and authorize permissions.

  • Just like that? I can’t ask my contacts to do it. Is there no other way to see the dates without their permission? I imagine that also without this login of them I will not be able to send a feed to them?

  • John, unfortunately not. You can try taggable_friends, but they do not come with birthday date and it is impossible to get the id true user to query birthday date. Since 2013 also not possible post a message to a friend’s Timeline by API. The options are to use a sharing window and / or the Apis for taggear friends.

  • That sucks, I thought I could automate my daily duties in the service. Because there are a lot of Books that I have to go in and send messages to their birthday kids every day. Just one more thing Anthoy as I write on a fan page. On the page I use the Post me/feed and on the fan Page. Thank you.

  • Yeah, Facebook restricts a lot of things for security reasons (and to avoid spam). You can post to /{page-id}/feed

Show 3 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.