[英]How to fetch a user's profile Picture from Facebook?
This is the PHP ode I am using 这是我正在使用的PHP颂歌
<?php
session_start();
include_once "fbconfig.php";
if($_SESSION["loggedin"] && file_exists("images/dp/$_SESSION[email].jpg"))
echo "<img src=\"images/dp/$_SESSION[email].jpg\" width=\"100px\">";
?>
This is the line to display the image 这是显示图像的行
<img class="user_img" src="\images/dp/$_SESSION[email].jpg\" width=\"100px\">
Here is the code to fetch other user information 这是获取其他用户信息的代码
$user_profile = $facebook->api('/me');
$fbid = $user_profile['id']; // To Get Facebook ID
$fbuname = $user_profile['username']; // To Get Facebook Username
if(empty($fbuname))
$fbuname = $user_profile['name']; // To Get Facebook full name
$femail = $user_profile['email']; // To Get Facebook email ID
checkuser($fbid,$fbuname,$femail,'fb'); // To update local DB
$_SESSION['userId'] = $fbuname;
This way the image does not appear where it should? 这样,图像不会出现在应该显示的位置? Where am i going wrong?
我要去哪里错了?
add prefix http://
in img source. 在img源中添加前缀
http://
。 ie src="http://graph.facebook.com/$fbid/picture"
即
src="http://graph.facebook.com/$fbid/picture"
or use the following 或使用以下
$profile_pic = "https://graph.facebook.com/$fbid/picture";
so, img src=" '.$profile_pic.' "
因此,img
src=" '.$profile_pic.' "
src=" '.$profile_pic.' "
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.