Skip to content

Instantly share code, notes, and snippets.

@caefer
Created March 9, 2011 21:35
Show Gist options
  • Save caefer/863054 to your computer and use it in GitHub Desktop.
Save caefer/863054 to your computer and use it in GitHub Desktop.
<?php
require __DIR__.'/vendor/facebook/src/facebook.php';
$app_id = '1234567890';
$secret = '0123456789abcdef0123456789abcdef0123456789abcdef';
$fb = new Facebook(array(
'appId' => $app_id,
'secret' => $secret,
'cookie' => false,
'fileUpload' => true // this is important !
));
// alternatively you can enable file upload on the instance
// $fb->setFileUploadSupport(true);
// the image you want to use on your event
$file = realpath('/path/to/your/example.jpg');
$eventInfo = array(
'name' => 'some title',
'start_time' => time()+32400,
'description' => 'some description',
basename($file) => '@'.$file,
// `-> 'example.jpg' => '@/path/to/your/example.jpg'
);
$result = $fb->api(
'/'.$app_id.'/events',
'post',
$eventInfo
);
echo 'Created event #'.$result['id'];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment