1

this is closely related to Twitter OAuth (PHP): Need good, basic example to get started , but not answered there. I need my website users to authenticate themselves, and then tweet a message whenever they log in. that's it. nothing complex. no pull, etc.

<?php

require "twitteroauth/autoload.php";
use Abraham\TwitterOAuth\TwitterOAuth;
$consumer_key = '25 chars';
$consumer_secret = '50 chars';

$connection = new TwitterOAuth($consumer_key, $consumer_secret);

$request_token = $connection->oauth("oauth/request_token", array("oauth_callback" => "http://mysite.info/twitter/twitter-back.php"));

session_start();
$_SESSION['oauth_token']=$request_token['oauth_token'];
$_SESSION['token_secret']=$request_token['oauth_token_secret'];

$url = $connection->url("oauth/authorize", array("oauth_token" => $oauth_token));

header('Location: ' . $url);

?>

but this throws an error

[Fri Nov 27 19:51:12.586244 2015] [:error] [pid 13738] [client 45.49.142.111:53338] PHP Fatal error: Uncaught exception 'Abraham\\TwitterOAuth\\TwitterOAuthException' with message '<?xml version="1.0" encoding="UTF-8"?>\n<hash>\n <error>Desktop applications only support the oauth_callback value 'oob'</error>\n <request>/oauth/request_token</request>\n</hash>\n' in /var/www/html/twitter/twitteroauth/src/TwitterOAuth.php:138\nStack trace:\n#0 /var/www/html/twitter/twitter-go.php(10): Abraham\\TwitterOAuth\\TwitterOAuth->oauth('oauth/request_t...', Array)\n#1 {main}\n thrown in /var/www/html/twitter/twitteroauth/src/TwitterOAuth.php on line 138

perhaps more importantly, to stop wasting everyone's time, I searched for a while for a minimal php setup that authenticates and then tweets 'hello'. it should be about 20 code lines to start, and 20 code lines to receive and post. it is easier to start with something working. can someone please point me to a current one?

Community
  • 1
  • 1
ivo Welch
  • 2,427
  • 2
  • 23
  • 31

0 Answers0