-
-
Save pietromalerba/4175c22f897a8ff6bfa5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// include Facebook PHP SDK | |
include "facebook/facebook.php"; | |
// init Facebook SDK with app settings | |
$facebook = new Facebook( array( 'appId' => APP_ID, 'secret' => APP_SECRET ) ); | |
// enable file upload support | |
$facebook->setFileUploadSupport( true ); | |
// set the page access token | |
$facebook->setAccessToken( PAGE_TOKEN ); | |
// upload a photo to facebook, will return id of uploaded photo | |
$photo_uploaded = $facebook->api( $page_id . "/photos", "POST", array( | |
'source' => '@' . 'cover.png', | |
'no_story' => true // suppress automatic image upload story, optional | |
) ); | |
// set uploaded photo as cover image, will return true on success | |
$cover = $facebook->api( $page_id, "POST", array( | |
'cover' => $photo_uploaded['id'], | |
'offset_x' => 0, // optional | |
'offset_y' => 0, // optional | |
'no_feed_story' => true // suppress automatic cover image story, optional | |
) ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment