function send_request2($url, $method = "get", $input = null) { $client = new RESTClient(); if ($method == "post") { $result = $client->post($url, $input); } elseif ($method == "get") { $result = $client->get($url, $input); } else { $result = "Error: no method specified"; } return $result; }
function send_request($url, $method = "get", $input = null) { global $restservicedir; $address = $restservicedir . $url; $client = new RESTClient(); if ($method == "post") { $result = $client->post($address, $input); } elseif ($method == "get") { $result = $client->get($address, $input); } else { $result = "Error: no method specified"; } return $result; }
/** * Fungsi untuk mendapatkan data ongkos kirim * @param integer $origin ID kota asal * @param integer $destination ID kota tujuan * @param integer $weight Berat kiriman dalam gram * @param string $courier Kode kurir, jika NULL maka tampilkan semua kurir * @return object Object yang berisi informasi response, terdiri dari: code, headers, body, raw_body. */ function getCost($origin, $destination, $weight, $courier = null) { $response = CJSON::decode($this->rest->post('api/cost', ['origin' => $origin, 'destination' => $destination, 'weight' => $weight, 'courier' => $courier])); return isset($response['rajaongkir']['results']) ? $response['rajaongkir']['results'] : null; }
/** * Get Google Plus rest API status * @param string $url * @return string[] */ public static function statusURLInGooglePlus($url) { $rest = new RESTClient(); $rest->initialize(array('server' => 'https://clients6.google.com/')); $rest->set_header('Content-type', 'application/json'); $rest->option('RETURNTRANSFER', true); $rest->option(CURLOPT_SSL_VERIFYPEER, false); $rest->option(CURLOPT_SSL_VERIFYHOST, false); $googlePlus = $rest->post('rpc', '[{"method":"pos.plusones.get","id":"p","params":{"nolog":true,"id":"' . rawurldecode($url) . '","source":"widget","userId":"@viewer","groupId":"@self"},"jsonrpc":"2.0","key":"p","apiVersion":"v1"}]'); $googlePlusStatus = CJSON::decode($googlePlus); return isset($googlePlusStatus[0]) ? $googlePlusStatus[0] : array(); }
/** * Fungsi untuk melacak paket/nomor resi * * @param string Nomor resi * @param string Kode kurir * @return string Response dari cURL, berupa string JSON balasan dari RajaOngkir */ function waybill($waybill_number, $courier) { $params = array('waybill' => $waybill_number, 'courier' => $courier); $rest_client = new RESTClient($this->api_key, 'waybill', $this->account_type); return $rest_client->post($params); }