php - TwitterOAuth: Uncaught exception 'This feature is temporarily unavailable' -
i working on application in wordpress allows users login using twitter accounts, , redirects users form. on submitting form, tweet sent user's twitter handle. i'm using abraham's twitteroauth
implement twitter oauth.
the source code of redirected template after successful twitter login:
<pre> <?php /* *template name: callback */ ?> <?php session_start(); require "twitteroauth/autoload.php"; use abraham\twitteroauth\twitteroauth; define('consumer_key', "xxxxxxxxxxxxxxx"); define('consumer_secret', "xxxxxxxxxxxxxx"); define('oauth_callback', " http://localhost/wordpress/index.php/callback/"); $request_token = []; $request_token['oauth_token'] = $_session['oauth_token']; $request_token['oauth_token_secret'] = $_session['oauth_token_secret']; if (isset($_request['oauth_token']) && $request_token['oauth_token'] !== $_request['oauth_token']) { echo "opps! went wrong!"; } else { $connection = new twitteroauth(consumer_key, consumer_secret, $request_token['oauth_token'], $request_token['oauth_token_secret']); $access_token = $connection->oauth("oauth/access_token", array("oauth_verifier" => $_request['oauth_verifier'])); //print_r($access_token); $_session['access_token'] = $access_token; } $access_token = $_session['access_token']; $connection = new twitteroauth(consumer_key, consumer_secret, $access_token['oauth_token'], $access_token['oauth_token_secret']); //$user = $connection->get("account/verify_credentials"); //$response = $connection->post("statuses/update", array('status' => 'fsociety')) //$response = $tmhoauth->request('post', $tmhoauth->url('1.1/statuses/update'), array( //'status' => 'conceit fall on parasol.' ?> <script> var count = 0 function addnewmessage(count) { if(count > 5) { window.alert("no more 5!"); } else { var celeb = document.createelement("input"); celeb.type = "text"; celeb.name = "tweet" + count; celeb.placeholder = "tweet" + " " + count; celebrity.appendchild(celeb); var date = document.createelement("input"); date.type = "datetime-local"; date.name = "date" + count; date.placeholder = "message-date" + " " + count; celebrity.appendchild(date); celebrity.appendchild(document.createelement("br")); celebrity.appendchild(document.createelement("br")); } } </script> <form method = "post" action = ""> <fieldset> <a style = "color:red" onclick = "addnewmessage(++count)">schedule tweet</a> <div id = "celebrity"/> </fieldset> <br> <fieldset> <input type="hidden" name="submitted" id="submitted" value="true" /> <?php wp_nonce_field( 'post_nonce', 'post_nonce_field' ); ?> <button type="submit"><?php _e('add campaign', 'framework') ?></button> </fieldset> </form> <?php if ( isset( $_post['submitted'] )) { $response = $connection->post("statuses/update", array('status' => 'fsociety')); } ?> </pre>
on submitting form, use abraham's twitteroauth
post tweet on user's twitter timeline, have tried implement follows:
<?php if ( isset( $_post['submitted'] )) { $response = $connection->post("statuses/update", array('status' => 'fsociety')); } ?>
however, error i'm encountering:
fatal error: uncaught exception 'abraham\twitteroauth\twitteroauthexception' message 'this feature temporarily unavailable' in /opt/lampp/htdocs/wordpress/wp-content/themes/twentyfifteen/tuto/twitteroauth/src/twitteroauth.php:137 stack trace: #0 /opt/lampp/htdocs/wordpress/wp-content/themes/twentyfifteen/tuto/callback.php(30): abraham\twitteroauth\twitteroauth->oauth('oauth/access_to...', array) #1 /opt/lampp/htdocs/wordpress/wp-includes/template-loader.php(74): include('/opt/lampp/htdo...') #2 /opt/lampp/htdocs/wordpress/wp-blog-header.php(16): require_once('/opt/lampp/htdo...') #3 /opt/lampp/htdocs/wordpress/index.php(17): require('/opt/lampp/htdo...') #4 {main} thrown in /opt/lampp/htdocs/wordpress/wp-content/themes/twentyfifteen/tuto/twitteroauth/src/twitteroauth.php on line 137
i tried debugging printing $access_token
, , i'm indeed getting unique token oauth provider expected.
what seems wrong code, , how avoid raising exception?
the exception thrown when oauth function check if returned code 200. encountered same problem , works : did add callback url on settings of app ? twitter uses setting > working localhost : 127.0.0.1/callback.php (then use geteven(oauth_callback) in define oauth_callback) use verify_credentials :)
Comments
Post a Comment