Server : Apache/2.4.18 (Ubuntu) System : Linux canvaswebdesign 3.13.0-71-generic #114-Ubuntu SMP Tue Dec 1 02:34:22 UTC 2015 x86_64 User : oppastar ( 1041) PHP Version : 7.0.33-0ubuntu0.16.04.15 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, Directory : /var/www/kanvakanva.com/public_html/application/controllers/ |
Upload File : |
<?php defined('BASEPATH') OR exit('No direct script access allowed'); class Rajaongkir extends Public_Controller { public function __construct() { parent::__construct(); } public function get_province() { //get province data from RajaOngkir.com $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'http://pro.rajaongkir.com/api/' . $uri, CURLOPT_RETURNTRANSFER => true, //not to print result, but return curl_exec as string, not as true/false CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, // The maximum amount of HTTP redirections to follow. Use this option alongside CURLOPT_FOLLOWLOCATION. CURLOPT_TIMEOUT => 30, //tell the script how long to wait to receive a completely buffered output from the server CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => array( 'key: 29b58cf87972eb123e184225147ce577' ), )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; } } public function get_city() { $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => "http://api.rajaongkir.com/starter/city?id=39&province=5", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => array( 'key: 29b58cf87972eb123e184225147ce577' ), )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; } } public function get_cost() { $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => "http://api.rajaongkir.com/starter/cost", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "origin=501&destination=114&weight=1700&courier=jne", CURLOPT_HTTPHEADER => array( "content-type: application/x-www-form-urlencoded", "key: 29b58cf87972eb123e184225147ce577" ), )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; } } }