如何根据mediawiki中的喜欢数量获得顶级文章

时间:2015-05-28 01:26:15

标签: php facebook facebook-like mediawiki

我对mediawiki比较陌生,上周刚刚开始。

任何人都可以指出我在mediawiki中获取顶级文章(基于喜欢的数量)的正确方向?我已经在每篇文章上实现了fblikebutton扩展,并设法检索每篇文章的喜欢数量。

我用来检查不同网址上每篇文章中的喜欢数量的代码

    $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/>';

例如: example.com/wiki/index.php?title=ABC(1 like) example.com/wiki/index.php?title=XYZ(2喜欢)

我试过了,但这不起作用

        $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/>';
            }
        }

我想检索example.com/wiki/index.php?title=XYZ中的内容并显示在“Top Article Page”中。在检索每个网址上每篇文章的喜欢数量之后,我该怎么做。我在热门文章中找到的扩展名基于观看次数。但我想根据喜欢的数量对顶级文章进行分类。

感谢一百万人的帮助!

1 个答案:

答案 0 :(得分:1)

正如我在评论中提到的那样,FQL已被弃用,而https://api.facebook.com/method/fql.query端点也被弃用。

如果您想要面向未来的东西,那么您应该切换到/?ids={url1},{url2},...端点。您可以使用此选项以正确的方式生成以逗号分隔的URL列表,然后在一个请求中检索所有共享,例如

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

返回

{
  "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's 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"
  }
}

您所拥有的排序问题与Facebook API无关,而是PHP。

相关问题