Skip to main content

Posts

PDUII FEEDER 02 Mata Kuliah dan Kurikulum

PDUII - FEEDER 01 Biodata dan Riwayat Pendidikan

CURL di CODEIGNITER

<?php class curl extends CI_Controller { public function __construct() { // created the construct so that the helpers, libraries, models can be loaded all through this controller parent::__construct(); $this->load->helper('url'); $this->load->library('xmlrpc'); $this->load->library('xmlrpcs'); } public function index() { //curl $mytoken = array('act'=>'GetToken', 'username'=>' ***** ', '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, CURLOPT_TIMEOUT, 60); 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', ...

Json encode dan decode

Logic Behind json encode and decode Encode array to json using  json_encode() <?php // This is a simple array $var1 = array( 'key_name1' => 'value_name1', 'key_name2' => 'value_name2' ); //We are converting array in encode $var1 array to json using json encode $encode_data = json_encode($var1); echo $encode_data; ?> Copy Result: Array Converted to JSON {"key_name":"value_name","key_name1":"value_name1"} Copy Decode json to array using  json_decode() <?php // This is a simple array, We are converting array in $var1 = array( 'key_name1' => 'value_name1', 'key_name2' => 'value_name2' ); //encode $var1 array to json using json_encode() $encode_data = json_encode($var1); echo $encode_data; //decode json data($encode_data) to array, using json_decode() $decode_data = json_decode($encode_data); print_r($decode_data); ?> Copy Result: ...

Token_Model

<?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_RETURNTRANS...

ws_client_act

<?php defined('BASEPATH') OR exit('No direct script access allowed'); error_reporting(E_ALL ^ E_WARNING ^ E_NOTICE ^ E_DEPRECATED); session_start(); class Ws_Client extends CI_Controller { public function __construct() { parent::__construct(); $this->load->library('session'); $this->load->helper('url'); $this->load->model('token/token_model','tkn'); } public function index() { $token = $this->tkn->token_feeder(); echo $token; } public function client() { $token = $this->tkn->token_feeder(); $filter = ''; $order = ''; $limit = 100; $offset = 0; $myProfil = array('act'=>'GetMatkulKurikulum', 'token'=>$token, 'filter'=>$filter, 'order'=>$order, 'limit'=>$limit, 'offset'=>$offset); $profil_pt = json_encode($myProfil); $ch = curl_init('http://...

Latihan

<html>     <head>         <script src="jquery-1.12.0.min.js"></script>         <script> $.ajax({ url         : "json.php", type        : "GET", dataType    : "json", data        : {get_param : 'value'}, success     : function(data){ var data = data; alert(data[0]["data"]["token"]) } }); </script>     </head> <body>     </body> </html>