I'm new to PHP and I have developed a system that automatically applies a watermark to a manually uploaded image. What I want to do is have a user sign in with their Facebook account, have the PHP get their profile picture from graph.facebook.com and then save it on my server under the /images directory.
I've been trying to do this for the past 4 and a half hours but I have no idea what i'm doing. I've tried to use Facebook's User Picture SDK but i have no idea how to apply it (clearly just copying and pasting isn't going to work haha). If someone could please provide me with some code, you certainly be mentioned on the final page.
To show image in page
<img src="//graph.facebook.com/{{fid}}/picture">
To save
$image = file_get_contents('https://graph.facebook.com/'.$fid.'/picture?type=large');
$dir = dirname(__file__).'/avatar/'.$fid.'.jpg';
file_put_contents($dir, $image);
Facebook Graph API
http://graph.facebook.com/abdulla.nilam/picture
You can use graph API to get user's image
https://graph.facebook.com/v2.2/USER_ID/picture?width=500&height=500
USER_ID will be user's Facebook ID.
You can set the width and height as required.
Related
I'm creating a social app similar to instagram on Android studio.
Users will be able to upload and view photos in this app.
The photos are saved on a Cloud in a folder called "ProfileImage" and the URL of the photos is saved on the MySql database, along with the ID of the photo and the user's ID.
To get the photos I would like to use Picasso.
If for example the user A wants to look at his photos, the app will have to show him only his photos, that is I will have to get the URLs of the photos that have the id of the user A.
Picasso to get the photos use the following code Picasso.get().load("http://i.imgur.com/DvpvklR.png").into(imageView);
But the problem is that I don't know the specific URL of the photos.
One solution I thought of is to get the URLs of the photos via PHP and pass them into an android variable that I will use as a URL variable for Picasso.
But this solution seems slow to me, in the sense that the photo will not be displayed immediately, but seconds will have to pass.
Can anyone recommend a faster and perhaps better solution than mine?
First of all, Upload your image to server and save image url inside mysql database not image itself. Create one api that returns user info including image url.
I've been using the PHP GraphObject API from Facebook to get the URL of the user's profile picture, and was just wondering if ALL the Facebook profile pictures are .JPG's ...
I wanted to know this so that I know whether I need to determine the file type before saving it (using file_get_contents() and file_put_contents() etc).
Many thanks.
i have a problem with og:image. Like i'm developing an facebook app and there is some steps in app. At last step user should share image that he/she created. But when i send url to created image to header for og:image, on share screen image can not be displayed. How can i solve this porblem? By the way i used debugger tool and there isn't any image either.
here is my debug link; http://corpusad.com/ecard/ecard/template_preview/64
Has Facebook released any api for facebook cover photo?
I want to implement it using PHP language.
EDIT
I want to upload cover photo in facebook timeline using graph api PHP
There is an api for updating the cover photo on a page
http://developers.facebook.com/docs/reference/api/page/
It asks for a photo id which i guess is the id of a photo from the users album.
Actually, it is not possible to change the profile picture directly via Facebook Photo Graph API as no section mention about that.
However, we can do a trick by uploading user’s photo to Facebook via the API then redirect the user to uploaded photo URL with 1 added in querystring parameter as below:
http://www.facebook.com/photo.php?pid=xyz&id=abc&makeprofile=1
“&makeprofile=1″ is the main thing here and xyz/abc will be returned by Facebook. By adding the parameter, Facebook will auto change the profile picture of the current user with the uploaded picture above.
For more info:
http://4rapiddev.com/facebook-graph-api/php-change-facebook-profile-picture-with-graph-api/
You can upload photo to an album via graph api. Get the new photo id and redirect user to this url
"http://www.facebook.com/profile.php?preview_cover=" + photo_id
before that, you should inform the user that he/she will be redirected to facebook to page where they can set new cover photo (they need to confirm the change, click the save button). It's not perfect solution, and not fully covered api but it's best way out there asfaik.
I am reading the Facebook API and I am google'ing for a method or function to be able to set an image as profile picture.
I need to know if something like this is possible at all.
In the old REST Api you find a note, that it isn't possible to upload a picture into the users profile pic album. But.. is this step required for my transaction?
I would like to know which methods/function I have to take and/or an advice how to code.
(trivial workflow of app: user visits fb-app, user clicks on button, user gets an request-alert to allow action, user gets manipulated picture as own profile picture)
thanks in advance
chris
Sorry, but not is possible. If you take a look here:
http://developers.facebook.com/docs/api
At the "Publishing" section the /PROFILE_ID/picture is not writable even if you can upload a photo to an album.