54 lines
1.1 KiB
PHP
54 lines
1.1 KiB
PHP
<?php
|
|
namespace Open;
|
|
|
|
use Open\Client;
|
|
use Helpers\Curl;
|
|
use Helpers\Table;
|
|
|
|
class OAuth2 extends \Zend_Controller_Plugin_Abstract
|
|
{
|
|
public $db;
|
|
public $auth = NULL;
|
|
public $user;
|
|
private $config;
|
|
public $table;
|
|
|
|
public function __construct($db = NULL,$auth = NULL){
|
|
|
|
if(empty($db))
|
|
{
|
|
$this->db = \Zend_Registry::get('db');
|
|
}else{
|
|
$this->db = $db;
|
|
}
|
|
|
|
$this->config = \Zend_Registry::get('config');
|
|
$this->table = new Table();
|
|
|
|
}
|
|
|
|
//登录测试
|
|
public function loginTest()
|
|
{
|
|
try {
|
|
$client = new Client();
|
|
$url = $client->makeRequestCodeUrl("escience");
|
|
|
|
$curl = new Curl();
|
|
$curl->port = 443;
|
|
$curl->initOptions(array('verifyssl' => false));
|
|
$data = $curl->request($url, array(), "POST");
|
|
|
|
$cache_data = $data;
|
|
|
|
if (isset($data['headers']['http_code']) && $data['headers']['http_code'] == 302) {
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
}catch (\Exception $e)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
} |