0
我成功地使用laravel創建服務器和客戶端應用程序,我也可以從服務器應用程序訪問數據到客戶端應用程序。但是現在我想用codeigniter創建另一個客戶端應用程序。除了回調方法,授權工作。那麼如何將此代碼轉換成CodeIgniter 2?Laravel護照「轉換授權碼到訪問令牌」codeigniter的代碼
Route::get('/callback', function (Request $request) {
$http = new GuzzleHttp\Client;
$response = $http->post('http://your-app.com/oauth/token', [
'form_params' => [
'grant_type' => 'authorization_code',
'client_id' => 'client-id',
'client_secret' => 'client-secret',
'redirect_uri' => 'http://example.com/callback',
'code' => $request->code,
],
]);
return json_decode((string) $response->getBody(), true);
});
?
謝謝