Jump to content

cURL request to valid url returning 400 error.


defeated

Recommended Posts

Hi,

Could somebody please explain to me why the following code returns a 400 error.  I've been sitting looking at it for hours and I can't see anything wrong with it, but then again I don't know too much about cURL.

<?php

// INSTANTIATE CURL.
$curl = curl_init();

// CURL SETTINGS.
curl_setopt($curl, CURLOPT_URL, "http://twitter.com/statuses/user_timeline/96966578.xml");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 0);

// GRAB THE XML FILE.
$response = curl_exec($curl); 
// Get information about the response 
$responseInfo=curl_getinfo($curl); 
// Close the CURL connection curl_close($curl);
curl_close($curl);

// Make sure we received a response from Twitter 
if(intval($responseInfo['http_code'])==200){ 
	// Display the response from Twitter 
	$content .= "Success code response:". $response; 
}else{ 
	// Something went wrong 
	$content .= "Error: " . $responseInfo['http_code']; 
} 


// SET UP XML OBJECT.
$xmlObjTwitter = simplexml_load_string( $response );

$content .="<h3>Your last 10 twitter posts....</h3>\n" ; 

$content .= "<ul> \n";

$tempCounter = 0;

foreach ( $xmlObjTwitter -> item as $item )
{                    
    // DISPLAY ONLY 10 ITEMS.
    if ( $tempCounter < 11 )
    {
        $content .= "<li><a href=\"{$item -> guid}\">{$item -> title}</a></li>
";
    }

    $tempCounter += 1;
}

$content .="</ul>\n";

echo $content ;


?>

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.