这是使用 Zend 从 URL 获取 json 响应的正确方法吗?顺便说一下,我正在尝试从 Instagram API 获取信息(http://instagram.com/developer/authentication/)
public function getAccessToken($code) {
$config = Zend_Registry::get('config');
$client = new Zend_Http_Client('https://api.instagram.com/oauth/access_token');
$client->setMethod(Zend_Http_Client::POST);
$client->setParameterPost('client_id', $config['social']['instagram']['client_id']);
$client->setParameterPost('client_secret', $config['social']['instagram']['client_secret']);
$client->setParameterPost('grant_type', 'authorization_code');
$client->setParameterPost('redirect_uri', $config['social']['instagram']['redirect_uri']);
$client->setParameterPost('code', $code);
$body = $client->request();
return $body->getBody();
}
我只是得到一个奇怪的回应,比如:
string '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Instagram</title>
<meta name = "viewport" content = "width = 320px">
<link rel="stylesheet" href="/static/styles/master-new.css?1" type="text/css" media="screen" title="no title" charset="utf-8">
</head>
<body>
<div id="wrap" class="grid-all group">
<div style'... (length=726)
有任何想法吗?顺便说一句,我在 Zend 中有点菜鸟,所以请确保你也考虑一下非常明显的事情:)