How to get the top article based on the number of similar ones in the media

I am relatively new to the media and just got started last week.

Anyone can point me in the right direction for getting the top article (based on likes) on mediawiki? I've already implemented the fblikebutton extension for each article and was able to get the number of likes for each article.

The code I used to check the number of likes in each article at different urls

    $query_for_fql  = "SELECT like_count FROM link_stat WHERE url = '".$full_url."'";
    $fqlURL = "https://api.facebook.com/method/fql.query?format=json&query=" . urlencode($query_for_fql);
    $response = file_get_contents($fqlURL);
    $json_data = json_decode($response);
    $fb_like_count = $json_data[0]->like_count;
    echo 'Facebook Like:'.$fb_like_count .'<br/>';

      

eg: example.com/wiki/index.php?title=ABC (1) example.com/wiki/index.php?title=XYZ (2 times)

I tried this but it doesn't work

        $highest = 0;
        while($highest < $fb_like_count)
        {
            if($fb_like_count > $highest) //if loop at first
            {
                $highest = $fb_like_count;
                echo "highest value is " . $highest . '<br/>';
            }
        }

      

I want to get content at example.com/wiki/index.php?title=XYZ and display it on the Home page. What should I do next after getting the number of likes for each article on each url. The extensions I've found for the top articles are based on views. But I want to categorize the top article based on likes.

Thanks a million for the help!

+3


source to share


1 answer


As I said in my comment to you, FQL is deprecated and endpoint https://api.facebook.com/method/fql.query

.

If you want something reliable, then you must go to the end point /?ids={url1},{url2},...

. You can use this to generate a comma separated list of urls in the forehand and then get all domains in one request like

GET /?ids=http://www.techcrunch.com,http://www.google.com

      

returns



{
  "http://www.techcrunch.com": {
    "og_object": {
      "id": "433841427570", 
      "title": "TechCrunch", 
      "type": "website", 
      "updated_time": "2015-05-27T21:31:39+0000", 
      "url": "http://techcrunch.com/"
    }, 
    "share": {
      "comment_count": 0, 
      "share_count": 20914
    }, 
    "id": "http://www.techcrunch.com"
  }, 
  "http://www.google.com": {
    "og_object": {
      "id": "381702034999", 
      "description": "Search the world information, including webpages, images, videos and more. Google has many special features to help you find exactly what you're looking for.", 
      "title": "Google", 
      "type": "website", 
      "updated_time": "2015-05-28T07:10:18+0000", 
      "url": "http://www.google.com/"
    }, 
    "share": {
      "comment_count": 2, 
      "share_count": 12340803
    }, 
    "id": "http://www.google.com"
  }
}

      

The sorting problem you are having is not related to the Facebook API, but PHP.

Cm

+1


source







All Articles