views:

290

answers:

2

Im looking at the Twitter API: http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-account%C2%A0update_profile

I want to update my profile via PHP.

Specifically my location: San Francisco, CA

Im not looking for anything fancy, just a way of calling the XML, checking its contents, then writing in a new value if appropriate.

Can anyone point me in the right direction?

+1  A: 
public function updateProfile($name = null, $email = null, $url = null, $location = null, $description = null)
    {
        // validate parameters
        if($name === null && $email === null && $url === null && $location === null && $description === null) throw new TwitterException('Specify at least one parameter.');
        if($name !== null && strlen($name) > 40) throw new TwitterException('Maximum 40 characters allowed for name.');
        if($email !== null && strlen($email) > 40) throw new TwitterException('Maximum 40 characters allowed for email.');
        if($url !== null && strlen($url) > 100) throw new TwitterException('Maximum 100 characters allowed for url.');
        if($location !== null && strlen($location) > 30) throw new TwitterException('Maximum 30 characters allowed for location.');
        if($description !== null && strlen($description) > 160) throw new TwitterException('Maximum 160 characters allowed for description.');

        // build parameters
        if($name !== null) $aParameters['name'] = (string) $name;
        if($email !== null) $aParameters['email'] = (string) $email;
        if($url !== null) $aParameters['url'] = (string) $url;
        if($location !== null) $aParameters['location'] = (string) $location;
        if($description !== null) $aParameters['description'] = (string) $description;

        // make the call
        $response = $this->doCall('account/update_profile.xml', $aParameters, true);

        // convert into xml-object
        $xml = @simplexml_load_string($response);

        // validate
        if($xml == false) throw new TwitterException('invalid body');

        // return
        return (array) $this->userXMLToArray($xml, true);
    }
streetparade
Could you give me an idea of how i would use this?
danit
not after you down voted my answer
streetparade
I didnt down vote it at all!
danit
ok first you need a twitter library if you want i can give you my twitter library http://www.code.google.com/p/twitter-boot you will find it http://code.google.com/p/twitter-boot/source/browse/trunk/twitter-bot/inc/twitter/twitter.php here include it in your script look at the twitter-bot ihave written you will find many examples
streetparade
I imagine your were voted down for your comments below, however thank you for your assitance.
danit
you are welcome if you have questions for the bot fom google code which i wrote you can mail me [email protected]
streetparade
+2  A: 
curl -u user:password -d "location=San Francisco, CA" http://twitter.com/account/update_profile.xml
erenon
However come July this year Twitter will be phasing this simple Authorization out, and you'll need to use OAuth...
Scott Herbert
are all peoples drunk the guy above asked how to do it using php
streetparade