Worked perfectly, thanks Chad! I'm sure I'll have another problem soon, but for now I'm rolling. Thanks again! :D
On Jan 7, 8:05 pm, "Chad Etzel" <[email protected]> wrote: > I think the XML parser will choke on the headers that are being > returned from your curl_exec. > > Try setting this instead: > curl_setopt($ch, CURLOPT_HEADER, false); > > You'll also want to set this: > curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); > > so that the XML is actually stored in $str when curl_exec returns; > > Try that out, > -Chad > > On Wed, Jan 7, 2009 at 6:29 PM, [email protected] > > <[email protected]> wrote: > > > Hello everyone, > > I'm working on my first Twitter-related project and am very excited to > > be doing so. > > > What I'm trying to do is create a site that lists my > > "friends_timeline." With that account, I'm following a group of > > individuals in a particular industry. > > > Right now, I've been able to use curl to display the raw XML. Now I'm > > struggling to display that data the way I need to. > > > Here's what I have written. > > > <blockquote> > > <?php > > // set user/pswd > > $username = '123'; > > $password = 'abc'; > > > // create a new curl resource > > $ch = curl_init(); > > > // set URL and options > > curl_setopt($ch, CURLOPT_URL, "http://twitter.com/statuses/ > > friends_timeline/ACCOUNT+NAME.xml"); > > curl_setopt($ch, CURLOPT_HEADER, 1); > > curl_setopt($ch, CURLOPT_USERPWD, "$username:$password"); > > > // execute and pass to browser > > $str = curl_exec($ch); > > > // close curl resource > > curl_close($ch); > > > $xml = simplexml_load_string ($str); > > foreach ($xml->status as $status) { > > print $status->text . "\n"; > > } > > > ?></blockquote> > > > Again, this outputs the last 20 entries in "friends_outline" as XML > > just fine, but fails at the array. The following appears immediately > > afterward. > > > <blockquote> > > Warning: simplexml_load_string() [function.simplexml-load-string]: > > Entity: line 1: parser error : Start tag expected, '<' not found in / > > projects/tweets/test/curltest.php on line 20 > > > Warning: simplexml_load_string() [function.simplexml-load-string]: 1 > > in /projects/tweets/test/curltest.php on line 20 > > > Warning: simplexml_load_string() [function.simplexml-load-string]: ^ > > in /projects/tweets/test/curltest.php on line 20 > > > Warning: Invalid argument supplied for foreach() in /projects/tweets/ > > test/curltest.php on line 21</blockquote> > > > I only have rudimentary PHP skills, but I'm a fairly quick study. Any > > advice is appreciated! > > > Thanks in advance for the help! > > > --Alex
