Created
June 24, 2013 20:20
-
-
Save gregimba/5853266 to your computer and use it in GitHub Desktop.
This file contains 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
<form action="tweet.php" method="post"> | |
<p>Your tweet: <input type="text" name="tweet" /></p> | |
<p>Your @(handle): <input type="text" name="handle" /></p> | |
<p><input type="submit" /></p> | |
</form> |
This file contains 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 | |
require 'vendor/autoload.php'; | |
$consumerKey = 'xxxxxxxxxxxxxxxxxxxxx'; | |
$consumerSecret = 'xxxxxxxxxxxxxxxxxxxxx'; | |
$accessToken = 'xxxxxxxxxxxxxxxxxxxxx'; | |
$accessTokenSecret = 'xxxxxxxxxxxxxxxxxxxxx'; | |
$twitter = new Twitter($consumerKey, $consumerSecret, $accessToken, $accessTokenSecret); | |
try { | |
$tweet = $twitter->send($_POST['tweet'].' by '.$_POST['handle'] ); | |
} catch (TwitterException $e) { | |
echo 'Error: ' . $e->getMessage(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Assuming your Twitter library returns false on a the
send
method in the event of a failure (which I'd hope it does), you could avoidtry
/catch
by doing something like: