Help with status/update posts with Twitteroauth under API v 1.1


#1

With API v1.1 coming into play, and the subsequent blackouts leading up to it, it took me a while to realize I needed to update my PHP scripts. All these scripts do is post to my Twitter account updates to my site, people who won contests, etc., allowing me to free up time for other pressing matters.

My problem now, however, is that I’m at a total loss…I can’t wrap my head around the changes…I’ve downloaded Abraham’s latest Twitteroauth package, and have tried numerous methods for posting, and nothing seems to be working…so I throw myself on the mercy of those of you with sharper minds than my own.

My old script was easy:

session_start();
	   
$connection = new TwitterOAuth ($consumer_key ,$consumer_secret , $access_key , $access_secret );
$content = $connection->get('account/verify_credentials');
$connection->post('statuses/update', array('status' => $tmessage));</code>

But with the new APIs, this isn't working (naturally), and try as I might, I can't get them working using what I believe to be the right approach, from reading these support boards over the last couple of weeks.  I've tried a variety of methods, but ultimately, I'm not sure exactly what I'm doing.

Can anyone help a poor old sad sack make it here?

#2

Still desperate to get this straightened out…I can get partial results still using the old API, but…

argh…just confused…


#3

If I’m reading Abraham’s readme correctly, this should work, but it doesn’t…
session_start();

		$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $_SESSION['oauth_token'], $_SESSION['oauth_token_secret']);
		$token_credentials = $connection->getAccessToken($_REQUEST['oauth_verifier']);
		
		$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $token_credentials['oauth_token'], $token_credentials['oauth_token_secret']);

		/* If method is set change API call made. Test is called by default. */
		$account = $connection->get('account/verify_credentials');
		$status = $connection->post('statuses/update', array('status' => $tmessage));</php>

Getting tired and desperate here…this has been impacting us daily since this began las month, and I cannot for the life of me find the solution.


#4

I’ve gone back in from scratch, to figure this all out.

If I use index.php’s example, I can post to my profile with no problem. Using the EXACT SAME SCRIPT in my old script, it fails. WHY?

This is it, right here:

session_start();
require_once(‘twitteroauth-master/twitteroauth/twitteroauth.php’);
require_once(‘twitteroauth-master/config.php’);

/* If access tokens are not available redirect to connect page. /
if (empty($_SESSION[‘access_token’]) || empty($_SESSION[‘access_token’][‘oauth_token’]) || empty($_SESSION[‘access_token’][‘oauth_token_secret’])) {
header(‘Location: twitteroauth-master/clearsessions.php’);
}
/
Get user access tokens out of the session. */
$access_token = $_SESSION[‘access_token’];

/* Create a TwitterOauth object with consumer/user tokens. */
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $access_token[‘oauth_token’], $access_token[‘oauth_token_secret’]);

/* If method is set change API call made. Test is called by default. */
$content = $connection->get(‘account/verify_credentials’);

$connection->post(‘statuses/update’, array(‘status’ => $tmessage));

There is no reason on God’s Green Earth this should be failing now…it works in one script but not the other, same server, same me…


#5

go here https://dev.twitter.com/discussions/1272


#6

try to create new variable of consumerkey and cunsumersecret like this

require_once(‘twitter/twitteroauth.php’);

$cKey = you cKey;
$cSecret = you cSecret;

$oTweet = new TwitterOAuth($cKey, $cSecret, $_SESSION[‘oauth_token’], $_SESSION[‘oauth_secret’]);
$oTweet->post(‘statuses/update’, array(‘status’ => $sMessage));
var_dump($oTweet);

i try and succes


#7

Ok all examples are fit only for authenticaed user. what if the application are for people taht visited my website and want to tweet to hos/her comments from my website

I dont want people to be popped up with a box of logon and write the tewi from that box.

I dont find any solution for this yet.

Plese help me


#8

If you want users to be able to tweet from your site (and you don’t want to use the Tweet Button or Tweet Web Intent) then you’re going to need to use OAuth and have the end-user explicitly give you permission to work with their account (to do things like sending a tweet on their behalf to statuses/update).

Take a look at the Tweet Web Intent if you haven’t already.


#9

You can see my post:

http://www.lmcdevloper.es/?p=220

I hope it help you.