简体   繁体   English

Facebook共同好友API

[英]Facebook Mutual Friends API

Using the Facebook Graph API (v2.4), I can't seem to access any information about mutual friends, not even the total count. 使用Facebook Graph API(v2.4),我似乎无法访问有关共同朋友的任何信息,甚至无法访问总数。

Here's my graph query (User ID changed for privacy purposes): https://graph.facebook.com/v2.4/123456789?fields=context.fields(mutual_friends) 这是我的图形查询(出于隐私目的更改了用户ID): https : //graph.facebook.com/v2.4/123456789?fields=context.fields(mutual_friends)

The result I get is: 我得到的结果是:

 { "context": { "id": "dXNlcl9jb250ZAXh0OgGQBqWf9ZAHMZA1yjZBJZABsMDkDORNsle8wkS8Acci9r4FsOdyRVl1TSGSXAsofmlaWYS05piSZCV9F1QwNNs0L9XpNuGLAaLyMk8Fnaiwyxpm5shUZD" }, "id": "123456789" } 

I tried using FB's iOS SDK to make the same query as well, but got the same result. 我尝试使用FB的iOS SDK进行相同的查询,但得到的结果相同。

Any suggestions? 有什么建议么?

The all_mutual_friends , mutual_friends , and three_degree_mutual_friends context edges of the Social Context API were deprecated on April 4, 2018 and immediately started returning empty data sets. Social Context APIall_mutual_friendsmutual_friendsthree_degree_mutual_friends上下文边缘已于2018年4月4日弃用,并立即开始返回空数据集。 They have now been fully removed. 它们现在已被完全删除。

The {user_id} must be another user of your app, and the user access token you MUST use is from another user of your app. {user_id}必须是您应用程序的另一个用户,并且您必须使用的用户访问令牌来自您应用程序的另一个用户。

Then 然后

GET /{user_id}?fields=context{mutual_friends}&access_token={other_users_access_token}

should work and give results, if both users gave your app the user_friends permission. 如果两个用户都向您的应用授予了user_friends权限,则应该可以正常工作并给出结果。

See 看到

function aa_mutl_frnd(x, row)
{ 
  FB.init({
    appId      : '<?php echo get_option('_fb_apps_id');?>', //Facebook apps id     using theme option
    cookie     : true,  // enable cookies to allow the server to access 
                    // the session
    xfbml      : true,  // parse social plugins on this page
    version    : 'v2.5' // use graph api version 2.5
  });  
  FB.getLoginStatus(function(response) {
    if (response.status === 'connected') {
            var accessToken = response.authResponse.accessToken;
            console.log(':acc_tk:'+accessToken);
//////////////////////////////////////////////////////////
            var data={
                'action': 'wq_accss_tkn_gnrt',
                'ddt'   :  accessToken
            }

            $.post('<?php echo admin_url('admin-ajax.php'); ?>', data, function (response) {
            console.log(':acc_tk2:'+response);


        FB.api(
                "/"+x+"",
                {
                    "fields": "context.fields(all_mutual_friends)",
                    //"access_token": '',
                    "appsecret_proof": response,
                },
                function (response) {
                    console.log(response);     
                }
        );

        });
////////////////////////////////////
        }
  });

}
/// ajax part /////
add_action('wp_ajax_wq_accss_tkn_gnrt', 'wq_accss_tkn_gnrt');
    add_action('wp_ajax_nopriv_wq_accss_tkn_gnrt', 'wq_accss_tkn_gnrt');    
        function wq_accss_tkn_gnrt() {
        echo hash_hmac('sha256',$_POST['ddt'],'app_secret');;
        die();
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM