简体   繁体   English

如何使用Codeigniter从Facebook登录api获取个人资料图片

[英]how to get profile picture from facebook login api using codeigniter

$user = $this->facebook->request('get', '/me?fields=id,name,email,first_name,link,picture');
<?php 
 $i=0;
 if($i<1)
 {
 foreach ($user as $key => $value):
 echo $key; 
 ?> : 

  <?php
 $image_url= $value; 
 echo $image_url;
  ?> 
 <img class="fb_profile" src="https://graph.facebook.com/<?php echo $image_url; ?>/picture">
 <?php   
 endforeach;
 }
 ?>

I have used https://github.com/darkwhispering/facebook-sdk-codeigniter for using facebook login sdk using codeigniter. 我已经使用https://github.com/darkwhispering/facebook-sdk-codeigniter通过codeigniter使用Facebook登录sdk。 I have got the values from it. 我从中得到了价值。 BUt in case of fetching user profile picture, i print repeated image tag with info of a given user. 在获取用户个人资料图片的情况下,我会打印具有给定用户信息的重复图像标签。 i havent been able to find other way without error and and only get one image. 我一直没有找到错误的其他方法,只能得到一张图像。 Other than picture i get the values just fine 除了图片,我得到的值就很好

要获取用户的个人资料图片,请使用提供的Facebook ID,我没有使用图片字段,但这应该可以:

<img class="fb_profile" src="https://graph.facebook.com/<?php echo $user['id']; ?>/picture">

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

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