<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Token_model extends CI_Model {
public function __construct()
{
parent::__construct();
$this->load->library('session');
$this->load->helper('url');
}
public function token_feeder()
{
$username = '*****';
$password = '*****';
$data_sesi=array(
'username'=>$username,
'password'=>$password,
'sudah_login'=>true,
);
$this->session->set_userdata($data_sesi);
$username=$this->session->userdata('username');
$password=$this->session->userdata('password');
$mytoken = array('act'=>'GetToken', 'username'=>$username, 'password'=>$password);
$payload = json_encode($mytoken);
$ch = curl_init('http://192.168.30.99:8082/ws/live2.php');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($payload))
);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($payload))
);
$result = curl_exec($ch);
$character = json_decode($result);
$token = $character->data->token;
return $token;
curl_close($ch);
}
}
?>
defined('BASEPATH') OR exit('No direct script access allowed');
class Token_model extends CI_Model {
public function __construct()
{
parent::__construct();
$this->load->library('session');
$this->load->helper('url');
}
public function token_feeder()
{
$username = '*****';
$password = '*****';
$data_sesi=array(
'username'=>$username,
'password'=>$password,
'sudah_login'=>true,
);
$this->session->set_userdata($data_sesi);
$username=$this->session->userdata('username');
$password=$this->session->userdata('password');
$mytoken = array('act'=>'GetToken', 'username'=>$username, 'password'=>$password);
$payload = json_encode($mytoken);
$ch = curl_init('http://192.168.30.99:8082/ws/live2.php');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($payload))
);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($payload))
);
$result = curl_exec($ch);
$character = json_decode($result);
$token = $character->data->token;
return $token;
curl_close($ch);
}
}
?>
Comments
Post a Comment