PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, February 11, 2022

[FIXED] An empty array of likes even though correct permissions - Facebook App

 February 11, 2022     facebook, facebook-php-sdk     No comments   

Issue

I'm going slightly mad because of my problem. I prepared facebook app based on facebook-php-sdk. My app's permisions are:

publish_acions, user_location, user_likes, friends_likes

Everything goes correct with that code:

$facebook = new Facebook(array(
  'appId'  => '####',
  'secret' => '####',
));

I can also receive

$user = $facebook->getUser();
$user_profile = $facebook->api('/me');
$userId = $user_profile['id'];

But I can't receive

$user_likes = $facebook->api('/me/likes/');

It just gives me an empty array (I'm quite sure I like the page). So what's the reason? Thanks in advance...


Solution

First of all: Use The JavaScript for the login process, it´s much easier to handle and debug. Also, it´s better for the usability, because it does not redirect: https://developers.facebook.com/docs/reference/javascript/FB.login/v2.1

Use the "scope" parameter as it is mentioned in the docs and check if the required permissions are really asked for in the authorization popups.

Btw, the correct endpoint would be /me/likes (without the slash at the end), just another idea why it does not work.

And then there is the review process, most permissions (like user_likes) need to get approved by Facebook before they can be used for other users (except for users with a role in the App settings). Check out the changelog and the review guidelines for more information:

  • https://developers.facebook.com/docs/apps/changelog
  • https://developers.facebook.com/docs/apps/review/login

Friend permissions are deprecated btw, there is no "friends_likes" anymore.



Answered By - andyrandy
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing