Skip to content

Instantly share code, notes, and snippets.

@BenjaminKobjolke
Created October 16, 2014 13:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BenjaminKobjolke/058ecd305d7ee0a41921 to your computer and use it in GitHub Desktop.
Save BenjaminKobjolke/058ecd305d7ee0a41921 to your computer and use it in GitHub Desktop.
read remote xml file
$c = curl_init();
$url = getfile($twitter_id . ".xml");
curl_setopt($c, CURLOPT_URL, $url);
//e cho "http://twitter.com/statuses/user_timeline/" . $twitter_id . ".xml" . "<br>";
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_CONNECTTIMEOUT, 3);
curl_setopt($c, CURLOPT_TIMEOUT, 5);
$response = curl_exec($c);
$responseInfo = curl_getinfo($c);
curl_close($c);
if (intval($responseInfo['http_code']) == 200) {
if (class_exists('SimpleXMLElement')) {
$xml = new SimpleXMLElement($response);
return $xml;
} else {
//return $response;
}
} else {
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment