Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to save save user's facebook profile picture to my domain/website data using php

i want to save the user's profile picture of facebook to my disk, it is more like scrapping user's profile picture db when they registered first.'

for example here is the url.

https://graph.facebook.com/{id}/picture

i want to save it under a specific directory. also, if there is not picture, i want to download the default placeholder as well, which is GIF. the above url is actually having a placeholder only.

i am beginner in php, please explain me in detail.

like image 533
asm234 Avatar asked Jan 18 '23 04:01

asm234


1 Answers

<?php
$image = file_get_contents('https://graph.facebook.com/100003027438870/picture'); // sets $image to the contents of the url
file_put_contents('/path/image.gif', $image); // places the contents in the file /path/image.gif
?>
like image 128
Tyilo Avatar answered Jan 20 '23 16:01

Tyilo