# Pure client-side call to Twitter API

**URL:** <https://forum.kirupa.com/t/pure-client-side-call-to-twitter-api/302416>\
**Category:** web dev\
**Created:** [December 30, 2009, 3:25am UTC](https://forum.kirupa.com/t/pure-client-side-call-to-twitter-api/302416 "2009-12-30T03:25:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![NeoDreamer](https://avatars.discourse-cdn.com/v4/letter/n/ccd318/32.png) [@NeoDreamer](https://forum.kirupa.com/u/NeoDreamer)\
**Post date:** [December 30, 2009, 3:25am UTC](https://forum.kirupa.com/t/pure-client-side-call-to-twitter-api/302416/1 "2009-12-30T03:25:54Z")

</div>

I have already figured out how to update someone’s Twitter status using PHP’s curl. These are the 3 major lines:

```php

curl_init('http://twitter.com/statuses/update.xml');
curl_setopt($ch, CURLOPT_POSTFIELDS, 'status=my new twitter status');
curl_setopt($ch, CURLOPT_USERPWD, 'myUsername:myPassword');

```

I was wondering if I could take load off of my server by not using curl. Would it be possible to directly call the [twitter.com](http://twitter.com) URL with AJAX? How do you do this “Basic Authentication” protocol with AJAX?

I’m using Prototype.js and I’m having difficulty finding articles on it. So far, I have this. It lacks the Basic Authentication part, so it will fail.

```php

new Ajax.Request(
    'http://twitter.com/statuses/update.json', {
        method: 'post',
        parameters: {
            status: 'my new twitter status'
        }
    }
);

```
