Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6060569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:50:27+00:00 2026-05-23T08:50:27+00:00

I’ve a facebook app which posts in the user wall. In the post there

  • 0

I’ve a facebook app which posts in the user wall. In the post there is a link (to my app) and in the liked page there is a like button.

Now I’m making a script that will run once per hour (set from the crontab). In that script I need to get two different likes count:

  1. Likes in the message posted in the wall.
  2. Likes done in my app (with the button).

For the first one I’ve made this code:

$result = $facebook->api(array(
              'method' => 'fql.query',
              'query' => 'SELECT user_id FROM like WHERE post_id="'.$idPost.'"'
          ));
$likesWall = count($result);

This code was working, but suddenly it is not. It throws this exception:

Fatal error: Uncaught Exception: 190:
Error validating access token: The
session is invalid because the user
logged out. thrown in C:\(…)\facebook\base_facebook.php
on line 656

For the second likes count

I really don’t know how I have to do it. I’ve tried:

$result = $facebook->api(array(
              'method' => 'links.getStats',
              'urls' => $canvasPage."somePage.php?id=".$id
          ));

But this throws:

Fatal error: Uncaught CurlException:
60: SSL certificate problem, verify
that the CA cert is OK. Details:
error:14090086:SSL
routines:SSL3_GET_SERVER_CERTIFICATE:certificate
verify failed thrown in
C:\(…)\facebook\base_facebook.php
on line 759

And then this was given to me: http://graph.facebook.com/?ids=http://apps.facebook.com/appName/somePage.php?id=68&metadata=1 where the bold part is the url in the like button I created. When I put it in the browser it returns me a JSON with some information (including the likes count) but I don’t know how to use it in my script.

More information:

Here is the code to define facebook object:

include_once 'facebook/facebook.php';
$facebook = new Facebook(array(
    'appId'  => $appId,
    'secret' => $secret
  ));

I’m using the latest version the SDK (v3).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T08:50:27+00:00Added an answer on May 23, 2026 at 8:50 am

    I found it!

    I made it this way:

    function get_content($url){
        $options = array(
            CURLOPT_RETURNTRANSFER => true,     // return web page
            CURLOPT_HEADER         => false,    // don't return headers
            CURLOPT_FOLLOWLOCATION => true,     // follow redirects
            CURLOPT_ENCODING       => "",       // handle all encodings
            CURLOPT_USERAGENT      => "spider", // who am i
            CURLOPT_AUTOREFERER    => true,     // set referer on redirect
            CURLOPT_CONNECTTIMEOUT => 120,      // timeout on connect
            CURLOPT_TIMEOUT        => 120,      // timeout on response
            CURLOPT_MAXREDIRS      => 10,       // stop after 10 redirects
            CURLOPT_SSL_VERIFYPEER => false,
            CURLOPT_SSL_VERIFYHOST => 2,
        );
    
        $ch      = curl_init( $url );
        curl_setopt_array( $ch, $options );
        $content = curl_exec( $ch );
        $err     = curl_errno( $ch );
        $errmsg  = curl_error( $ch );
        $header  = curl_getinfo( $ch );
        curl_close( $ch );
    
        $header['errno']   = $err;
        $header['errmsg']  = $errmsg;
        $header['content'] = $content;
        //return $header;
        return $content;
    }
    
    $facebook = new Facebook(array(
        'appId'  => $appId,
        'secret' => $secret
    ));
    
    $accessToken = get_content("https://graph.facebook.com/oauth/access_token?type=client_cred&client_id=".$appId."&client_secret=".$secret);
    $accessToken = substr($accessToken, strpos($accessToken, "=") + 1);
    
    $fqlResult = get_content("https://api.facebook.com/method/fql.query?query=SELECT+user_id+FROM+like+WHERE+post_id%3D\"".$idPost."\"&format=json&access_token=".$accessToken);
    $fqlResult = json_decode($fqlResult);
    $countLikesWall = count($fqlResult);
    
    $fqlResult = get_content("https://api.facebook.com/method/fql.query?query=SELECT+like_count+FROM+link_stat+WHERE+url%3D\"http%3A%2F%2Fapps.facebook.com%2F**MyAppsName**%2F**somePage**.php%3Fid%3D".$id."\"&format=json&access_token=".$accessToken);
    $fqlResult = json_decode($fqlResult);
    
    $countLikesUrl = $fqlResult[0]->like_count;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.