Auto Tweet PHP Script - Help

Hi there,

I am creating an Auto-Tweet Script and it’s almost working except for 2 things that I need some help with.

Here is the script so far:

<?php // Sets the Timezone
date_default_timezone_set('Europe/London'); ?>


<?php // Setup the report

$today = date ('m/d/Y');
$todayuk = date ('d M Y');

$file = 'url_to_xml_file_goes_here';
$xml = simplexml_load_file($file);


$longstring = $xml->content;
$truncated = substr($longstring,0,strpos($longstring,' ',100));
$msg = $truncated;

?>

<?php // Let's show the URL at the end of the tweet.
$short_url = 'http://bit.ly/nxoA33';
?>


<?php // And now connect to Twitter!

$consumerKey    = 'key_goes_here';
$consumerSecret = 'secrect_goes_here';
$oAuthToken     = 'token_goes_here';
$oAuthSecret    = 'secret_goes_here';
 
require_once($_SERVER['DOCUMENT_ROOT'].'/scripts/twitteroauth.php');
 
// create a new instance
$tweet = new TwitterOAuth($consumerKey, $consumerSecret, $oAuthToken, $oAuthSecret);
 
//send the tweet.

$tweet->post('statuses/update', array('status' => $msg, $short_url));
	
?>

The problem I have is that in the very last line, I have asked the script to tweet the content and the short_url afterwards but it’s missing off the short url - The tweet works but it only tweets the content in the $msg variable.

Also, I need to write something before the $msg variable. So I want the tweet to be like this:

My Text $msg $short_url

Can somebody help me with these two things?

Looks like in order to do that you would need to include the include_entities option than define a single entity with the [url=https://dev.twitter.com/docs/tweet-entities]url.

This is the search string I ran on Google to find that info: api tweet post.