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.
Related
I'm doing preliminary research for an upcoming project. Basically here is the user/data flow:
A webcam at an event takes pictures and sends the photos to a local server
A brand rep has an iPad with an app (developed as an HTML app saved to iPad home screen as an app). The app displays all photos from the local server as thumbnails via simple AJAX calls to load them into the view.
A user selects a photo. That photo will be sent from our local server to our remote server. The remote server will host a Facebook iFrame tab with the user selected photos.
At the same time, a link to the iFrame tab with a query string will be posted on the user's Facebook wall and Twitter (if they choose to authenticate of course).
Now the tricky part, we are 99% sure that the client is going to want to also upload the photo directly to the Facebook user's album. Possibly to TwitPic as well but that is a secondary concern. So my question is, is there a way to use PHP to upload a photo to a Facebook wall without using a typical html file input field and POST? Ideally, if we can do some kind of a file_get_contents on the photo URL from the local server and use PHP/FB API to upload the contents of the photo URL, we'd be in great shape.
The goal is to have the photo uploaded to the user wall with a caption like:
Check out my photo taken at _ event! [URL to client facebook tab with photo id].
#jeremyharris is right to say that Facebook's PHP SDK wraps cURL. You indeed need to use cURL to post a request to Facebook's API endpoint. Though, start by reading http://developers.facebook.com/docs/reference/api/ Publishing section to understand the mechanics before you jump onto their SDK.
Then familiarise with the feed object. You can use either it or the photo object to upload the photo.
We are developing a facebook iframe application that pulls some images (via an API) to the current user album (creates a new one).
The user views his newly uploaded album photos using a facebook lightbox clone. In this clone he must be able to comment and like the current viewed photo.
Is there a way to provide facebook comments & like to these pictures without the use of the Graph API (which would require us to replicate a lot of visuals).
Another try was the social plug-ins with the facebook photo url given but no success.
Any ideas?
I would recommend using the social plugins that facebook provide.
For the likes and comments you can specify a URL in the plugin code, that URL should be the URL of the photo relative to your app e.g. http://myapp.com/photo/123 and not the http://app.facebook.com address.
Facebook will need to be able to crawl that URL so if you are checking if the user is logged in via PHP then you should either disable this if the user agent contains facebookexternalhit or show a different page for that user agent. It doesn't matter about the content, just set a couple of og: meta tags and that should be fine.
All available descriptions to upload an image to a fanpage use an album id, but
no one describes the format of the id and how to get it.
Are there examples of php code to get the album id of an album on a fanpage
and examples to upload an image to that page
Here are the steps you will need to build, using the graph api.
Get the facebook ID for the page.
Get an access_token from the page you want to upload to.
Make a form to POST to "https://graph.facebook.com/". $_userID . "/photos?access_token=". $_accessToken
The image will be uploaded to a folder with the same name as you app. So if your app is called "Magic Photo Uploader", the photos will go into a folder called "Magic Photo Uploader Photos"
In my experience you will not need an album ID, I think that documentation is outdated, since for all my apps it makes a album for those app photos and I cannot rename it. But there was once upon a facebook, a REST API that used to let you create and populate albums. Not sure if that is still accessible as a legacy.
Is it possible to set/change a user's facebook profile image through the graph API?
I can't find a specific API method, but it is possible to upload an image to a user's album (http://developers.facebook.com/docs/reference/api/photo). Can I set the user's profile image to an image uploaded to their album?
Edit:
Same question asked in reference to REST API
Can I set a users profile image using the Facebook API?
No, And here's a comment from a guy at facebook:
The Original Link - you have to press show comments
We can do a trick by uploading user’s photo to Facebook via the API then redirect the user to uploaded photo URL with makeprofile=1 added to the list of query strings:
facebook.com/photo.php?pid=xyz&id=abc&makeprofile=1
Check Auto Change Facebook Profile Picture to get PHP example and demo.
Currently this is possible by redirecting the user to the mobile profile pic change url, https://m.facebook.com/photo.php?fbid=[fb photo id]&prof&ls=your_photo_permalink
The previous work around, using the facebook.com/photo.php?pid=[fb photo id]&makeprofile=1 url no longer works.
To the best of my knowledge and experience: No.
See the "Publishing" section here: http://developers.facebook.com/docs/reference/api/photo
Requires the publish_stream
permission.
To publish a photo, issue a POST
request with the photo file attachment
as multipart/form-data.
You can publish an individual photo to
a user profile with a POST to
http://graph.facebook.com/PROFILE_ID/photos
We automatically create an album for
your application if it does not
already exist. All photos from your
application will be published to the
same automatically created album.
You can publish a photo to a specific,
existing photo album with a POST to
http://graph.facebook.com/ALBUM_ID/photos.
The last sentence states you can publish to an existing album, so if you're trying to update the user's profile picture (not sure from the way you stated your question), try getting the album ID for the user, then publishing to that.
Can you post a photo to the wall of a friend of the logged-in user using the FB Graph API? I could find no posts that answered this exact question but if there are please point me in the right direction.
I have tried the code found in answers to this question to post a photo, but no matter what user id is used in the call to api, the photo gets added to an album on the logged-in user's profile.
Is it possible to post a photo to another user's profile - just like one any user can manually add to someone's Wall Photos? i.e, a post that will have type: "photo" in the graph API instead of type "link".
Even while going through the old publish documentation, they specify you can only include attachments using links to the media you'd like to attach and not by uploading directly through the API. Looks like this is the route you're going to have to go (using the link property you've already mentioned)