SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Oct 2010
    Posts
    167
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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 Code:
    <?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?

  2. #2
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,192
    Mentioned
    17 Post(s)
    Tagged
    4 Thread(s)
    Looks like in order to do that you would need to include the include_entities option than define a single entity with the url.

    This is the search string I ran on Google to find that info: api tweet post.
    The only code I hate more than my own is everyone else's.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •