Hi Santanu,

The example code you have posted below makes use of basic authentication
(username and password). The Twitter API hasn't support this method of
authentication for a while and instead requires developers to implement
OAuth.

We have some guidance about how to make this transition on our developer
resources site:
    http://dev.twitter.com/pages/basic_to_oauth

You may also find our single user token example helpful:
    http://dev.twitter.com/pages/oauth_single_token

Best,
@themattharris <https://twitter.com/intent/follow?screen_name=themattharris>
Developer Advocate, Twitter



On Thu, Jun 16, 2011 at 11:33 PM, earth technology 8 <
earthtechnolo...@gmail.com> wrote:

> 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
>

-- 
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