spandansingh/auth-server-api
Composer 安装命令:
composer require spandansingh/auth-server-api
包简介
Auth Server API for PHP
关键字:
README 文档
README
Auth Server API is a PHP HTTP client for Auth Server that makes it easy to send HTTP requests and trivial to integrate with web services.
- Manages things like persistent connections, simplifies sending streaming POST requests with fields ,and abstracts away the underlying HTTP transport layer.
- Set the cookie on your server by the token issued by the Auth Server
- Easy login and logout function
- Auth Server API makes it so that you no longer need to fool around with cURL options, stream contexts, or sockets for connecting with Auth Server.
Usage
$auth = new Auth\ApiClient(array( 'KEY' => AUTH_KEY, // YOUR AUTH KEY 'SECRET' => AUTH_SECRET, // YOUR AUTH SECRET 'LOGIN_URI' => '/login.php', // YOUR APP LOGIN URL ));
For Check Login Status
- If the user is logged in, it returns the user information array.
- If it is not logged in, it redirects to the auth server login page
$token = isset($_SESSION[‘auth_server_token’])?$_SESSION[‘auth_server_token’]:NULL ; // If you save token in session than you can receive it like this . if($user = $auth -> isloggedIn($token)){ echo ‘welcome’.$user[‘first_name’].’’.$user[‘last_name’]; }
For Login
$response = $auth -> dologin(); $token = $auth -> getToken(); $_SESSION[‘auth_server_token’] = $token; header(‘location:’ , $auth ->getcallbackUri()); // After Saving token redirect to the callback_url() session_write_close(); .
For Logout
unset($_SESSION['auth_server_token']); $auth->doLogout();
Installing via Composer
The recommended way to install Auth Server API is through Composer.
# Install Composer curl -sS https://getcomposer.org/installer | php
Next, run the Composer command to install the latest stable version of Auth Server API:
composer require spandansingh/auth-server-api:dev-master
After installing, you need to require Composer's autoloader:
require 'vendor/autoload.php';
Sample app
Check out Auth Server Demo App for a quick sample app.
Consultation
- Spandan Singh
- Looking for PHP web development solutions or consultation? Drop me a mail.
统计信息
- 总下载量: 82
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2015-02-06