Posting to Twitter from PHP - used to work before August 2010

Just spotted on a blog system I made last year that the entries arent heading up to Twitter as they should do. It looks like August 2010 was the point where things stopped working and having searched the net there seem to be loads of posts about oAuth but I cant find the correct info on the twitter site to even begin to look at things.

		$url = '';
		// Alternative JSON version
		// $url = '';

		$curl_handle = curl_init();
		curl_setopt($curl_handle, CURLOPT_URL, "$url");
		curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
		curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($curl_handle, CURLOPT_POST, 1);
		curl_setopt($curl_handle, CURLOPT_POSTFIELDS, "status=$messagex");
		curl_setopt($curl_handle, CURLOPT_USERPWD, "$username:$password");
		$buffer = curl_exec($curl_handle);
		// check for success or failure
		if (empty($buffer)) {
				echo 'Post failed. Please add listing manually.';
		} else {
				echo 'Success';

It always showed Success! when running so I stupidly never went to the twitter feed to see if that was right.

Has anyone got some drop in code I can replace the above with to get things rocking again?

Many thanks :slight_smile:


Basic authentication was phased out during the end of last year for oAuth due to better security while logging in with it. Read the following article as it explains oAuth status updates using a simple pre-built class.

Thank you. I will chec this out! :slight_smile:

Gave that a go and using the files it recommends Im getting caught at the first hurdle:

Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or ‘}’ in /home/xxxx/public_html/twitteroauth.php on line 17