why the twitter is redirecting when the page does not exists.
In this code why the twitter site is redirecting when the requested page www.twitter.com/misc/drupal.js
does not exists in the site www.twitter开发者_JAVA技巧.com
. Why the status is not 404
.
<?php
include ("HttpClient.class.php");
$client = new HttpClient('www.twitter.com');
$client*enter code here*->setDebug(true);
$client->get('/misc/drupal.js');
echo $client->getStatus();
?>
Output: 301 Moved Permanently.
You are requesting www.twitter.com. To keep with their short theme, they don't use www before their domain name. You are getting the 301 redirect because Twitter is asking you to request http://twitter.com/misc/drupal.js instead of http://www.twitter.com/misc/drupal.js. Try:
<?php
include('HttpClient.class.php');
$client = new HttpClient('twitter.com');
$client->get('/misc/drupal.js');
echo $client->getStatus();
?>
精彩评论