问题
There is an API support to update the cover photos for pages. Can I change my timeline cover photo using Facebook Graph API? There is a similar question in stack overflow click here. I have tried every solution in this question but I an unable to change the cover photo. I have used the method to update the page cover photo click here to see the documentation and this is the error
Fatal error: Uncaught OAuthException: (#10) Application does not have permission for this action
回答1:
After recent changes to Facebook api, we can only make cover photo of a page with photos which are in an album. We have to create an album and upload the photo to that album then we can use that photo as cover photo. Previously we can make cover from "photos of page's" album.
$args = array('name' => 'awesome album name', 'message' => 'awesome album message');
try {
$album_id =$facebook->api("/$page_id/albums", 'post', $args);
}catch(Exception $e){
echo $e->getMessage();
}
$args = array('image' =>'@'.realpath('/var/www/facebook.png'));
try{
$uploaded_photo_details = $facebook->api("/{$album_id['id']}/photos", 'post', $args);
}catch(Exception $e){
echo $e->getMessage();
}
if(isset($uploaded_photo_details['id'])){
$args = array('cover' => $uploaded_photo_details['id'], 'offset_y' =>0);
try {
$cover_details = $facebook->api("/{$page_id}", 'post', $args);
}catch(Exception $e){
echo $e->getMessage();
}
I wrote a complete tutorial about this http://blog.jambura.com/2012/12/05/change-facebook-pages-cover-photo-using-graph-api-and-page-api/
来源:https://stackoverflow.com/questions/17493384/how-to-update-the-profile-cover-photo-using-graph-api