Facebook的FQL网址喜欢的朋友工作奇怪 [英] Facebook FQL url likes of friends work strange

查看:145
本文介绍了Facebook的FQL网址喜欢的朋友工作奇怪的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想根据给定的网址来计算我的朋友的网址,我有以下代码:

 功能指数mQ(URL){

FB.api({
的access_token: 'CAACEdEose0cBABMG67fV8Yn5cHo5fkb6kT6npRWO7YQL8zagoFLrz5OFLFIEPVUJhMwf9rql9oAqktDUJMKBGr5NNRXJ73jf418gspbfklvdJs6Kx1EkCRutYhSnSW4Binb4F9AlOUIHfXZC052SOdlgtxTSng6gM4CAZAstpLAoOd1p5pnCpNadnlluMqOxjHo1jx1QZDZD',
法: 'fql.multiquery',
的查询: {
query1:SELECT total_count,like_count,click_count,normalized_url FROM link_stat WHERE url ='+ url +'
query2:SELECT url FROM url_like WHERE user_id IN(SELECT uid1 FROM friend WHERE uid2 = me())
}
},function(response){
console.log(response)
var urlLikes = 0;
var total = response [0] .fql_result_set [0] .total_count;
var likes = respons E [0] .fql_result_set [0] .like_count;
var clicks = response [0] .fql_result_set [0] .click_count;
var normalized_url = response [0] .fql_result_set [0] .normalized_url;
var results = response [1] .fql_result_set
console.log('Total:'+ total +',Likes:'+ likes +',Clicks:'+ clicks)
console.log 'Urls:'+ results.length)
console.log('============================ =====================================')
console.log ('检查url:'+ url);
console.log('===================================== $ var $ = $; $ < results.length; i ++){

var newUrl = decodeURI(url).toLowerCase();
var newFriendUrl = decodeURI(results [i] .url).toLowerCase();

if(newUrl == newFriendUrl){
urlLikes + = 1;
}

}

console.log('Url likes:'+ urlLikes);
});
}

我从第二个查询获得一个链接,这是一个url,我给它给我的一个朋友喜欢它后,他的计数器没有增加,而是url从第二个查询列表中删除!



我在这里做错了什么?

解决方案

您尝试实施的内容有多个问题:


  1. 在某些情况下,如何获取喜欢的用户ID有很多问题。简短的答案是 - 如果你花了太多的时间,没有找到一个解决方案 - 你不能轻易获得这些喜欢,或者根本不能让他们。所以,Facebook不会让你拥有喜欢特定网址的用户标识,你不会从Facebook找到一个简单的解决方案或指导文档。 类似问题参考


  2. 让我们考虑数字。如果你有100个朋友,他们都在Facebook的生活中喜欢至少100个网址。这意味着您的query2查询应该导致10,000个URL的集合,这对于fql查询是不实际的。在stackoverflow上有很多帖子,甚至在facebook博客文章上。您必须将这些查询限制为您测试的某个数字。有时可能是数以千计,有时也不会超过几百。在你的情况下,我会使用数百。所以,完成任务的一个方法是将query2限制为LIMIT 0,100 - 尝试一下,你会看到多重查询工作。接下来要做的是通过循环偏移参数对其余结果进行分页。所以,你必须制作100个fql请求才能获取你朋友喜欢的所有URL。因此:


  3. 您想要做的是不可能实时完成(一个查询)。


如果您的访问令牌具有user_likes和friends_likes权限,您需要查询 url_like 表。


Hi I would like to count the url likes of my friends based on a given url, I have the following piece of code:

    function mQ(url){

        FB.api({
            access_token:'CAACEdEose0cBABMG67fV8Yn5cHo5fkb6kT6npRWO7YQL8zagoFLrz5OFLFIEPVUJhMwf9rql9oAqktDUJMKBGr5NNRXJ73jf418gspbfklvdJs6Kx1EkCRutYhSnSW4Binb4F9AlOUIHfXZC052SOdlgtxTSng6gM4CAZAstpLAoOd1p5pnCpNadnlluMqOxjHo1jx1QZDZD', 
            method: 'fql.multiquery', 
            queries: {
                "query1":"SELECT total_count, like_count, click_count, normalized_url FROM link_stat WHERE url='"+url+"'",
                "query2":"SELECT url FROM url_like WHERE user_id IN (SELECT uid1 FROM friend WHERE uid2 = me())"
            } 
        }, function(response) {
            console.log(response)
            var urlLikes = 0;
            var total = response[0].fql_result_set[0].total_count;
            var likes = response[0].fql_result_set[0].like_count;
            var clicks = response[0].fql_result_set[0].click_count;
            var normalized_url = response[0].fql_result_set[0].normalized_url;
            var results = response[1].fql_result_set
            console.log('Total: ' +total+ ', Likes: ' + likes+ ', Clicks: ' +clicks)
            console.log('Urls: ' + results.length)
            console.log('=========================================================================')
            console.log('Checking for url: ' + url);
            console.log('=========================================================================')

            for(var i = 0; i < results.length; i++){

                var newUrl = decodeURI(url).toLowerCase();
                var newFriendUrl = decodeURI(results[i].url).toLowerCase();

                if (newUrl == newFriendUrl) {
                    urlLikes += 1;
                }

            }

            console.log('Url likes: ' + urlLikes);
        });
    }

I get one link from the second query which is a url and I give it to a friend of mine to like it after he does the counter doesnt increase but instead the url gets removed from the second query list!

What am'I doing wrong here?

解决方案

There are multiple issues with what you trying to implement:

  1. There are lot of questions about how to get user ids of likes in a certain circumstances. The short answer is - if you spent too much time and have not found a solution - you can't get those likes easily, or can't get them at all. So, facebook won't let you have the user ids that liked a specific urls, and you won't find a simple solution or guided documentation from facebook regards it. similar issue reference

  2. Lets think numbers. If you have 100 friends, and all of them liked at least 100 urls during their facebook life. It means that your "query2" query should result set of 10,000 urls, and this is not practical for fql query. There are a lot of posts about it on stackoverflow and even on facebook blog posts. You must limit such queries to a certain number that you have tested. Sometimes it might be thousands, and sometimes not more than few hundreds. In your case, i would use hundreds. So, one way accomplish your task is to limit query2 with "LIMIT 0,100" - try it and you'll see that the multyquery work. The next thing to do will be to "paginate" over the rest of the results by looping the offset parameter. So, you'll have to make 100 fql requests in order to get all the urls that your friends liked. Thus:

  3. What you trying to do is not possible to accomplish in real time (one query).

If your access token has the user_likes and friends_likes permissions that is all you need to query the url_like table.

这篇关于Facebook的FQL网址喜欢的朋友工作奇怪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆