所以我試圖用https://www.gosquared.com API和文檔的交互:站點令牌與codeigniter休息。
https://www.gosquared.com/developer/api/now/v3/aggregateStats/
我現在用笨與REST
和CURL
我有以下代碼:
public function __construct()
{
parent::__construct();
$this->load->library('admin/curl');
$this->load->library('admin/rest');
$this->rest->initialize(array(
'server' => 'https://api.gosquared.com/now/v3',
));
$this->rest->api_key('0000000000000000');
$this->rest->site_token('FFF-000000-F');
}
public function index()
{
$result = $this->rest->get('aggregateStats');
var_dump($result);
}
所以,這正在與服務進行交互,除了在api鍵之外,該服務還需要site_token
才能訪問我的信息。
隨着代碼我現在已經$this->rest->site_token('FFF-000000-F');
我得到這個具體的錯誤,當我加載頁面:
Fatal error: Call to undefined method REST::site_token()
如果我刪除的代碼行造成的錯誤,我得到這個作爲var_dump($result);
結果(因爲該網站令牌未獲得通過)
object(stdClass)#27 (2) { ["code"]=> int(4000) ["message"]=> string(162) "You must specify a site token. It looks like GSN-1234567-X and can be found in the developer section of your account area https://www.gosquared.com/home/developer" }
所以我的問題是:
如何在codeigniter中將額外變量site_token
傳遞到rest library
而不會收到任何錯誤?
根據該文件與該API進行交互看起來像一個有效的URL如下(爲它的價值)
https://api.gosquared.com/now/v3/aggregateStats?api_key=0000000000000000&site_token=FFF-000000-F