Following my last question again; This small script is supposed to grab my twitter friends feed and store the xml as a string. However, it keeps outputting all of the data (minus the xml, actually) to the browser. What am I doing wrong?
<html>
<head>
<title>Twitcap</title>
</head>
<body>
<?php
function twitcap()
{
// Set your username and password
$user = 'osoleve';
$pass = '********';
// Set site in handler for cURL to download
$ch = curl_init("https://twitter.com/statuses/friends_timeline.xml");
// Set cURL's option
curl_setopt($ch,CURLOPT_HEADER,0); // We want to see the header
curl_setopt($ch,CURLOPT_TIMEOUT,30); // Set timeout to 30s
curl_setopt($ch,CURLOPT_USERPWD,$user.':'.$pass); // Set uname/pass
curl_setopt($ch,CURLOPT_RETURNTRANSER,1); // Do not send to screen
// For debugging purposes, comment when finished
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,1);
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,1);
// Execute the cURL command
$xml = new SimpleXMLElement( curl_exec($ch) );
curl_close($ch);
// Return the data
return $xml;
}
$content = twitcap();
echo "Hello, world.<br /><br />";
?>
</body>
</html>
Oh, in case it makes a difference, I am using Chrome.