我正在尝试通过Box-Api设置授权流程。第一步必须是对授权URL的GET调用,它必须带有三个参数:
这是此次通话的示例代码:
class OauthController extends Zend_Controller_Action
{
public function indexAction()
{
$client = new Zend_Http_Client('https://www.box.com/api/oauth2/authorize');
$client->setMethod(Zend_Http_Client::GET);
$client->setParameterGet(array(
'response_type' => 'code',
'client_id' => 'xxxxxxxxxxxxxxxxxx',
'redirect_uri' => 'http://localhost/imball-reagens/callback'
));
$response = $client->request();
$this->_helper->viewRenderer->setNoRender(true);
return $response;
}
}
我已经在我的网站的主页上为这个控制器建立了一个链接,并且我已经删除了视图,因此Controller只能进行http调用。它应该使用Box.com的登录来支持用户,但它没有,而是只显示白页。 当我调用此控制器时,Zend服务器会发出警告:
Slow Request Execution
Request to http://localhost:10088/imball-reagens/public/oauth took 3042ms
答案 0 :(得分:0)
该程序必须写在主页的链接中。这是一个例子:
<a href="https://www.box.com/api/oauth2/authorize?response_type=code&client_id=xxxxxxxxx&redirect_uri=http://localhost/callback">Authorize Account Box API</a>