foreach ($xml->user as $user) {

$username = $user->name;
$userscreenname = $user->screen_name;
$userid = $user->id;

echo "<p class='text-name'>".$username."</p>";//status
echo "<p class='text-screenname'>".$userscreenname."</p>";//status
echo "<p class='text-screenname'>".$userid."</p>";//status

}


On Mon, May 18, 2009 at 00:13, Lorraine <lorrainema...@gmail.com> wrote:

> Thanks Abraham- I did that, but get the same problem with the looping. The
> same name of one user over and over again. Here's the updated code...
>
> <?php
> // set user/pswd
> $username = 'SweeterLorraine';
> $password = 'anaxwax';
>
> // create a new curl resource
> $ch = curl_init();
>
> // set URL and options
> curl_setopt($ch, CURLOPT_URL, "http://twitter.com/statuses/friends.xml";);
> curl_setopt($ch, CURLOPT_HEADER, false);
> curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
> curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
>
> // execute and pass to browser
> $str = curl_exec($ch);
>
> //print XML data (temporary)
> $xml = simplexml_load_string ($str);
>
> $username = $xml->user->name;
> $userscreenname = $xml->user->screen_name;
> $userid = $xml->user->id;
>
> foreach ($xml->user as $twit1) {
>
> echo "<p class='text-name'>".$username."</p>";//status
> echo "<p class='text-screenname'>".$userscreenname."</p>";//status
> echo "<p class='text-screenname'>".$userid."</p>";//status
>
> }
>
>
> // close curl resource
> curl_close($ch);
>
> ?>
>
>
>
> On Mon, May 18, 2009 at 11:54 AM, Abraham Williams <4bra...@gmail.com>wrote:
>
>> Try using http://twitter.com/statuses/friends.xml instead.
>>
>>
>> On Sun, May 17, 2009 at 13:38, Lorraine <lorrainema...@gmail.com> wrote:
>>
>>> Hope someone can help. I'm trying to generate a list of names and
>>> screen_names of the people I'm following on Twitter. The problem is that it
>>> just prints the name and screen_name of the user with the latest update...
>>> over and over again. I'm a real newbie when it comes to PHP-- here's my
>>> code:
>>>
>>> <?php
>>> // set user/pswd
>>> $username = 'TwitterName';
>>> $password = 'twitterpassword';
>>>
>>> // create a new curl resource
>>> $ch = curl_init();
>>>
>>> // set URL and options
>>> curl_setopt($ch, CURLOPT_URL, "
>>> http://twitter.com/statuses/friends_timeline.xml";);
>>> curl_setopt($ch, CURLOPT_HEADER, false);
>>> curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
>>> curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
>>>
>>> // execute and pass to browser
>>> $str = curl_exec($ch);
>>>
>>> //print XML data (temporary)
>>> $xml = simplexml_load_string ($str);
>>>
>>> $username = $xml->status->user->name;
>>> $userscreenname = $xml->status->user->screen_name;
>>>
>>> foreach ($xml->status as $twit1) {
>>>
>>> echo "<p class='text'>".$username."</p>";//status
>>> echo "<p class='text'>".$userscreenname."</p>";//status
>>> }
>>>
>>> // close curl resource
>>> curl_close($ch);
>>>
>>> ?>
>>>
>>> What am I doing wrong?
>>>
>>
>>
>>
>> --
>> Abraham Williams | http://the.hackerconundrum.com
>> Hacker | http://abrah.am | http://twitter.com/abraham
>> Web608 | Community Evangelist | http://web608.org
>> This email is: [ ] blogable [x] ask first [ ] private.
>>
>
>


-- 
Abraham Williams | http://the.hackerconundrum.com
Hacker | http://abrah.am | http://twitter.com/abraham
Web608 | Community Evangelist | http://web608.org
This email is: [ ] blogable [x] ask first [ ] private.
Sent from San Francisco, California, United States

Reply via email to