Reputation: 141
I am trying to download Facebook profile picture for Facebook application. For this, I'm getting the value of Facebook username/id in $uid
. echo $uid
is showing the correct result but it's not picking up the value when I use it in the following code:
echo $uid;
$imgDestinationPath = 'pic.jpg';
$link = 'http://graph.facebook.com/$uid/picture?type=large';
$content = file_get_contents($link);
file_put_contents($imgDestinationPath, $content);
error_reporting(E_ALL);
Moreover, when I put the Facebook username instead of $uid
, it downloads the picture then.
Please help. I'm new to PHP.
Upvotes: 0
Views: 185
Reputation: 2704
$uid does not get evaluated, try this instead:
$link = 'http://graph.facebook.com/'.$uid.'/picture?type=large';
or you can do it with a double quote:
$link = "http://graph.facebook.com/$uid/picture?type=large";
I would prefer the first solution. This makes the code more readable to me.
Upvotes: 1
Reputation: 23312
please use the " " in this statement
$link = "http://graph.facebook.com/$uid/picture?type=large";
will solve the problem
Upvotes: 1