Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //in Route:
- Route::post('/testAuthen', 'LoginController@login');
- //in Controller:
- private function authenticate( $username, $password ) {
- $post_data = http_build_query(
- array(
- 'url' => 'its2.cgi.ac.th',
- 'username' => $username,
- 'password' => $password
- )
- );
- $opts = array(
- 'http' => array(
- 'method' => 'POST',
- 'header' => 'Content-type: application/x-www-form-urlencoded',
- 'content' => $post_data
- )
- );
- $context = stream_context_create( $opts );
- $result = file_get_contents( self::AUTHEN_USER_URL, false, $context );
- $result_arr = json_decode( $result, true );
- return json_decode( $result, true );
- }
- public function login(Request $request)
- {
- echo $this->authenticate('natthawut', 'password');
- }
Add Comment
Please, Sign In to add comment