Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- defined('BASEPATH') or exit('No direct script access allowed');
- class Rest
- {
- var $API = "";
- protected $CI;
- function __construct()
- {
- $this->CI = &get_instance();
- $this->API = "https://192.168.1.36:8443/saber-cia-api/";
- }
- public function send($method, $url, $header, $data)
- {
- //print_r($this->API.$url);
- $ch = curl_init($this->API . $url);
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
- if ($data != null) {
- $req = json_encode($data);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
- }
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- //start for https request
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
- //end for https request
- if ($header != null) {
- curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
- }
- $result = curl_exec($ch);
- $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
- curl_close($ch);
- //print_r($httpcode);
- $response = json_decode($result, true);
- return $response;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement