简体   繁体   English

Yii-Hybridauth-如何导入Facebook用户的联系人列表

[英]Yii - Hybridauth - How to import contact list of facebook user

How to import contacts of user using Yii - hybrid auth for provider facebook. 如何使用Yii导入用户的联系人-提供者Facebook的混合身份验证。

I had searched more but i didn't find any solution. 我搜索了更多,但没有找到任何解决方案。

Is it possible to import contacts using Hybridauth. 是否可以使用Hybridauth导入联系人。 If not, suggest me any yii oauth login extension to login and import friends list of facebook user. 如果不是,建议我使用任何yii oauth登录扩展名来登录和导入Facebook用户的朋友列表。

I use Hoauth for Yii to log in with facebook. 我使用Hoauth for Yii登录Facebook。 It does have the capability to import the contact list though it's not fully documented/implemented. 尽管没有完整记录/未实现,但它确实具有导入联系人列表的功能。

Go into extensions/hoauth/HOAuthAction.php and within the oAuth() function, right after $userProfile = $oAuth->profile; $userProfile = $oAuth->profile;之后,进入extensions / hoauth / HOAuthAction.php并在oAuth()函数中$userProfile = $oAuth->profile; (after authentication) I call $userContacts = $oAuth->adapter->getUserContacts(); (经过身份验证后)我叫$userContacts = $oAuth->adapter->getUserContacts();

I decided I wanted to store this array when the user registers so I created a DB table called Contacts (id,user_id,provider,identifier, etc - check the $userContacts array). 我决定在用户​​注册时想存储此数组,因此创建了一个名为Contacts的数据库表(id,user_id,provider,identifier等-检查$ userContacts数组)。 Then later down in the same function I amend the code again to save the contacts like this: 然后稍后在同一函数中再次修改代码以保存联系人,如下所示:

// user was successfully logged in
// firing callback
if (sizeof($userContacts)) {
  foreach($userContacts as $contact) {
   $newcontact = new Contacts;
   $newcontact->identifier = $contact->identifier;
   // ... fill in all attributes either individually or mass
  }
  $newcontact->save();
}

NOTE: depending when you created your facebook app, this could or could not return your full friend list. 注意:根据您创建Facebook应用程序的时间,这可能会或无法返回您的完整朋友列表。 The new facebook API will only return the friends who are already using your app, so not the full list. 新的facebook API将仅返回已经在使用您的应用程序的朋友,而不是完整列表。 I suggest looking up Facebook API 2.0 function 我建议查找Facebook API 2.0函数

/invitable_friends / invitable_friends

.. this will work if your app is classified as Games and it has a Canvas version as well. ..如果您的应用程序被归类为“游戏”并且它也具有Canvas版本,则此方法将起作用。 Old apps can still get the friend lists but only for a limited time, facebook will cut off this access with API v2.0 旧应用仍然可以获取朋友列表,但仅在有限的时间内,facebook会使用API​​ v2.0切断此访问权限

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

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