我写了这段代码,它运行但不为我返回个人资料图片。我也仔细检查了获取图片的网址。我到底哪里错了?我还希望返回的图片大小为 150x150px。如何获得要显示的自定义尺寸。谢谢!
<?php
define('BASE_URL', 'http://api.twitter.com/1/users/profile_image/screen_name=');
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$handle = $_POST['handle'];
$size = 'bigger';
if (isset($handle) && isset($size)) {
$twitterURL = BASE_URL . $handle . '&size=' . $size;
}
}
?>
<!DOCTYPE HTML>
<html lang="it-IT">
<head>
<meta charset="UTF-8">
<title>Get TwitterPic</title>
<link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro:200' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="wrapper">
<h1>Get image from twitter</h1>
<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post">
<p><label for="handle">Twitter Handle</label>
<input type="text" id="twitter" name="handle" placeholder="Twitter Handle"></p>
<p><input type="submit" value="Get Twitter Pic"></p>
</form>
<?php if (isset($size) && isset($twitterURL)): ?>
<img src="<?= $twitterURL ?>">
<?php endif; ?>
</div>
</body>
</html>