Single user authentication for posting to twitter


#1

Hi Guy’s I need to write a php application that allows a single user (me) to POST to twitter. I have tried numerous tutorials, but end up getting error messages :frowning: . Could you share some simple php code that will allow me to POST to twitter by using Access tokens. Thanks :slight_smile:


#2

See [node:124]. Make sure you have created read and write access tokens.


#3

Thanks, I have tried @abraham’s PHP twitteroauth Library, but I seem to get the same errors over and over:
Notice: Undefined index: oauth_token in C:\wamp\www\test\twitteroauth\twitteroauth.php on line 82
Notice: Undefined index: oauth_token_secret in C:\wamp\www\test\twitteroauth\twitteroauth.php on line 82
Notice: Undefined index: oauth_token in C:\wamp\www\test\redirect.php on line 15
Notice: Undefined index: oauth_token_secret in C:\wamp\www\test\redirect.php on line 16

Ps I have modified the config.php file.
Please help
Thanks in advance


#4

I’m not familiar with working with this library in Windows environments. It’s likely a configuration issue of some kind, or you’re executing code that’s not relevant to what you’re trying to accomplish (or have entered keys in to accomplish).


#5

This error means that Twitter isn’t returning a request_token. If you are hardcoding an access token from a single user then you shouldn’t be using this method anyways.


#6

This is all you need to post a status to Twitter from a single account. You should also add some error handling.

<?php require_once('twitteroauth/twitteroauth.php');

/* Create a TwitterOauth object with consumer/user tokens. */
$connection = new TwitterOAuth(‘CONSUMER_KEY’, ‘CONSUMER_SECRET’, ‘ACCESS_TOKEN’, ‘ACCESS_TOKEN_SECRET’);

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


#7

Thank You Very Much … It works :wink: !


#8

pelase help me, i same problem