-
-
Save Thunder33345/5d98bc99f3d9a5a87151f4631116f4e5 to your computer and use it in GitHub Desktop.
Twitter API issue demostration
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 | |
function getNewTwitter($settings) | |
{ | |
return $twitter = new TwitterAPIExchange($settings); | |
} | |
function getCredtials(TwitterAPIExchange $twitter) | |
{ | |
$url = 'https://api.twitter.com/1.1/account/verify_credentials.json'; | |
$requestMethod = 'GET'; | |
return $twitter->buildOauth($url, $requestMethod)->performRequest(); | |
} | |
function postTweet(TwitterAPIExchange $twitter) | |
{ | |
$url = 'https://api.twitter.com/1.1/statuses/update.json'; | |
$post = ['status' => 'Testing123!']; | |
$requestMethod = 'post'; | |
return $twitter->buildOauth($url, $requestMethod) | |
->setPostfields($post)->buildOauth($url, $requestMethod) | |
->performRequest(); | |
} | |
$twitter = getNewTwitter($settings); | |
echo "Without recreating\n"; | |
echo getCredtials($twitter) . PHP_EOL; | |
echo postTweet($twitter) . PHP_EOL; | |
echo getCredtials($twitter) . PHP_EOL; | |
echo getCredtials($twitter) . PHP_EOL; | |
echo getCredtials($twitter) . "\n\n\n"; | |
echo "With recreating\n\n\n"; | |
echo getCredtials(getNewTwitter($settings)) . PHP_EOL; | |
echo postTweet(getNewTwitter($settings)) . PHP_EOL; | |
echo getCredtials(getNewTwitter($settings)) . PHP_EOL; |
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
Without recreating | |
{"id":"...}(REDACTED) | |
{"errors":[{"code":32,"message":"Could not authenticate you."}]} | |
{"errors":[{"code":32,"message":"Could not authenticate you."}]} | |
{"errors":[{"code":32,"message":"Could not authenticate you."}]} | |
{"errors":[{"code":32,"message":"Could not authenticate you."}]} | |
With recreating | |
{"id":"...}(REDACTED) | |
{"errors":[{"code":32,"message":"Could not authenticate you."}]} | |
{"id":"...}(REDACTED) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment