【问题标题】:how to get top article based on number of like in mediawiki如何根据 mediawiki 中的点赞数获取热门文章
【发布时间】:2015-08-10 07:43:51
【问题描述】:

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

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

我用来检查不同 URL 上每篇文章的点赞数的代码

    $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 个赞) 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 中的内容并显示在“热门文章页面”中。在检索到每个 url 上每篇文章的点赞数后,我接下来应该做什么。我为热门文章找到的扩展是基于浏览量的。但我想根据点赞数对置顶文章进行分类。

感谢一百万的帮助!

【问题讨论】:

  • 表link_stat从何而来?你用的是什么 fblike 扩展(链接)?
  • @Florian 嗨。我实现的 fblike 扩展来自此链接 mediawiki.org/wiki/Extension:FacebookLikeButton link_stat 表是来自 Facebook 的表。我用fql来查询点赞。感谢您的回复!
  • FQL 已弃用,https://api.facebook.com/method/fql.query 也已弃用。
  • @user1730935:请在stackoverflow.com/questions/30497923/…删除你自己的更脆弱的副本?

标签: php facebook facebook-like mediawiki


【解决方案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 有关。

【讨论】:

  • 感谢您的宝贵建议!但我试图获得喜欢而不是分享。您提供的建议是否也包括喜欢?抱歉问了这样的问题,我还在学习中。 :)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-10-17
  • 1970-01-01
  • 2020-06-10
  • 1970-01-01
  • 2014-09-08
  • 2021-09-05
  • 1970-01-01
相关资源
最近更新 更多