My Gist for reproducing Facebook bugs
Last active
October 2, 2015 13:48
-
-
Save honzajavorek/2252576 to your computer and use it in GitHub Desktop.
My Gist for reproducing Facebook bugs
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
[submodule "facebook"] | |
path = facebook | |
url = git://github.com/facebook/facebook-php-sdk.git |
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 | |
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