Hi All,

I have a news site. I want that when I post any news from my site, the
news title (small text) and my site link automatically posted on my
twitter account.

I got below codes in internet, but the codes did not work. Please see
this

-------------------------------------------------------------------------------------------------------------
<?php
        $username = "twitter_username";
        $password = "twitter_password";
        $message = '<a href="DOMAIN_NAME">Small News Text</a>';

        $url = 'http://twitter.com/statuses/update.xml';
        $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=$message");
        curl_setopt($curl_handle, CURLOPT_USERPWD, "$username:$password");
        $buffer = curl_exec($curl_handle);
        curl_close($curl_handle);
        if (empty($buffer)) {
         echo "<p align=\"center\" >".'Sorry, due to an error your Twitter
status could not be updated! Please check your username/password!'."</
p>";
        } else {
         echo "<p align=\"center\">".'Your Twitter status has successfully
been updated!'."</p>";
        }
        ?>
-------------------------------------------------------------------------------------------------------------

If there is any API or PHP script, please send me. Waiting for reply

Best Regards,
Santanu

-- 
Twitter developer documentation and resources: https://dev.twitter.com/doc
API updates via Twitter: https://twitter.com/twitterapi
Issues/Enhancements Tracker: https://code.google.com/p/twitter-api/issues/list
Change your membership to this group: 
https://groups.google.com/forum/#!forum/twitter-development-talk

Reply via email to