Skip to content

Instantly share code, notes, and snippets.

@honzajavorek
Last active October 2, 2015 13:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save honzajavorek/2252576 to your computer and use it in GitHub Desktop.
Save honzajavorek/2252576 to your computer and use it in GitHub Desktop.
My Gist for reproducing Facebook bugs
[submodule "facebook"]
path = facebook
url = git://github.com/facebook/facebook-php-sdk.git

My Gist for reproducing Facebook bugs

<?php
ini_set('error_reporting', E_ALL);
function dump($v) {
echo '<xmp>';
var_dump($v);
echo '</xmp>';
}
require dirname(__FILE__) . '/facebook/src/facebook.php';
$appId = '274219879328421';
$facebook = new Facebook(array(
'appId' => $appId,
'secret' => '50a787ab59d30f9c8f3237e84fde9853',
));
$facebook->setFileUploadSupport(TRUE);
if (!empty($_GET['del'])) {
$facebook->api('/' . $_GET['del'] . '/', 'DELETE');
echo '<p>Deleted. <a href="?">Try again</a></p>';
exit;
}
$image = dirname(__FILE__) . '/279905.jpg';
assert(file_exists($image));
$event = array(
'name' => 'Nicolas Sturm in Brno',
'start_time' => date('Y-m-d\TH:i:sO', strtotime('tomorrow 20:00')),
basename($image) => '@' . realpath($image),
'ticket_uri' => 'http://concertin.com/blabla',
'no_feed_story' => TRUE,
);
dump($event);
$message = array(
'link' => 'http://stage.concertin.com',
'message' => 'Test',
);
dump($message);
try {
$result = $facebook->api('/' . $appId . '/events', 'POST', $event);
dump($result);
} catch (Exception $e) {
echo '<p>Event creating failed.</p>';
dump($e);
exit;
}
assert(!empty($result['id']));
echo '<p>Success: <a href="https://www.facebook.com/events/' . $result['id'] . '">Nicolas Sturm in Hanover</a>.</p>';
echo '<p>(<a href="?del=' . $result['id'] . '">Delete it</a>)</p>';
try {
$id = $result['id'];
$result = $facebook->api('/' . $id . '/feed', 'POST', $message);
dump($result);
} catch (Exception $e) {
echo '<p>Message posting failed.</p>';
dump($e);
exit;
}
assert(!empty($result['id']));
echo '<p>Success, message posted.</p>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment