PHP code example of littlechou / line-login
1. Go to this page and download the library: Download littlechou/line-login library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
littlechou / line-login example snippets
use LineProfile;
public function lineCallBackProfile(Request $request){
$code = $request->get('code');
$profile = LineProfile::get($code);
}
use LittleChou\LineLogin\ConfigManager;
use LittleChou\LineLogin\LineProfiles;
use LittleChou\LineLogin\LineAuthorization;
class LineController extends CI_Controller {
private $lineConfig;
public function __construct() {
$config = new ConfigManager();
$config->setRedirectUri("YOUR-REDIRECT-URI")
->setScope("YOUR-SCOPE")
->setClientSecret("YOUR-CLINET-SECRET")
->setClientId("YOUR-CLIENT-ID");
$this->lineConfig = $config;
}
/**
* 產生連結
*
*/
public function lineLogin() {
$auth = new LineAuthorization($this->lineConfig);
echo $auth->createAuthUrl();
}
/**
* 取得使用者資訊
*
*/
public function getLineProfile() {
$code = $this->input->get('code');
$lineProfile = new LineProfiles($this->lineConfig);
$profile = $lineProfile->get($code);
}
}