GodsDev/Backyard/BackyardBriefApiClient.php
public function sendJsonLoad($json, $httpVerb = 'POST')
    {
        $communicationId = uniqid(date("Y-m-d-His_"));
        $this->logCommunication($json, $httpVerb, $communicationId);
        $ch = curl_init($this->apiUrl);
        curl_setopt_array($ch, array(
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_POSTFIELDS => $json, //json_encode($postData)
            CURLOPT_SSL_VERIFYPEER => false,
            CURLOPT_SSL_VERIFYHOST => false, //accepts also private SSL certificates //@todo it could be possible to try without that option and if it fails, it may try with this option and inform about it
        ));
        switch ($httpVerb) {
            case 'POST':
                curl_setopt($ch, CURLOPT_POST, true);
            case 'GET':
            case 'DELETE':
                curl_setopt_array($ch, array(
                    CURLOPT_HTTPHEADER => array(
                        //'Authorization: '.$authToken,
                        'Content-Type: application/json'
                    ),
                ));
                if (in_array($httpVerb, array('GET', 'DELETE'))) {
                    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $httpVerb);
                }
                break;
            case 'PUT':
                curl_setopt_array($ch, array(
                    CURLOPT_HTTPHEADER => array(
                        //'Authorization: '.$authToken,
                        'Content-Type: application/json',
                        'Content-Length: ' . strlen($json)
                    ),
                    CURLOPT_CUSTOMREQUEST => 'PUT',
                ));
                break;
            default:
                $this->logger->error("Unknown verb {$httpVerb}");
                return false;
        }
        $result = curl_exec($ch);
        if ($result) {
            $this->logCommunication($result, 'resp', $communicationId);
        } elseif (!is_null($this->logger)) {
            $this->logger->error("Curl failed with (" . curl_errno($ch) . ") " . curl_error($ch));
        }
        return $result;
    }
public function sendJsonLoad($json, $httpVerb = 'POST')
    {
        $communicationId = uniqid(date("Y-m-d-His_"));
        $this->logCommunication($json, $httpVerb, $communicationId);
        $ch = curl_init($this->apiUrl);
        curl_setopt_array($ch, array(
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_POSTFIELDS => $json, //json_encode($postData)
            CURLOPT_SSL_VERIFYPEER => false,
            CURLOPT_SSL_VERIFYHOST => false, //accepts also private SSL certificates //@todo it could be possible to try without that option and if it fails, it may try with this option and inform about it
        ));
        switch ($httpVerb) {
            case 'POST':
                curl_setopt($ch, CURLOPT_POST, true);
            case 'GET':
            case 'DELETE':
                curl_setopt_array($ch, array(
                    CURLOPT_HTTPHEADER => array(
                        //'Authorization: '.$authToken,
                        'Content-Type: application/json'
                    ),
                ));
                if (in_array($httpVerb, array('GET', 'DELETE'))) {
                    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $httpVerb);
                }
                break;
            case 'PUT':
                curl_setopt_array($ch, array(
                    CURLOPT_HTTPHEADER => array(
                        //'Authorization: '.$authToken,
                        'Content-Type: application/json',
                        'Content-Length: ' . strlen($json)
                    ),
                    CURLOPT_CUSTOMREQUEST => 'PUT',
                ));
                break;
            default:
                $this->logger->error("Unknown verb {$httpVerb}");
                return false;
        }
        $result = curl_exec($ch);
        if ($result) {
            $this->logCommunication($result, 'resp', $communicationId);
        } elseif (!is_null($this->logger)) {
            $this->logger->error("Curl failed with (" . curl_errno($ch) . ") " . curl_error($ch));
        }
        return $result;
    }
public function sendJsonLoad ( $ json , $ httpVerb = 'POST' ) { $ communicationId = uniqid ( date ( "Y-m-d-His_" ) ) ; $ this -> logCommunication ( $ json , $ httpVerb , $ communicationId ) ; $ ch = curl_init ( $ this -> apiUrl ) ; curl_setopt_array ( $ ch , array ( CURLOPT_RETURNTRANSFER => true , CURLOPT_POSTFIELDS => $ json , //json_encode($postData) CURLOPT_SSL_VERIFYPEER => false , CURLOPT_SSL_VERIFYHOST => false , //accepts also private SSL certificates //@todo it could be possible to try without that option and if it fails, it may try with this option and inform about it ) ) ; switch ( $ httpVerb ) { case 'POST' : curl_setopt ( $ ch , CURLOPT_POST , true ) ; case 'GET' : case 'DELETE' : curl_setopt_array ( $ ch , array ( CURLOPT_HTTPHEADER => array ( //'Authorization: '.$authToken, 'Content-Type: application/json' ) , ) ) ; if ( in_array ( $ httpVerb , array ( 'GET' , 'DELETE' ) ) ) { curl_setopt ( $ ch , CURLOPT_CUSTOMREQUEST , $ httpVerb ) ; } break ; case 'PUT' : curl_setopt_array ( $ ch , array ( CURLOPT_HTTPHEADER => array ( //'Authorization: '.$authToken, 'Content-Type: application/json' , 'Content-Length: ' . strlen ( $ json ) ) , CURLOPT_CUSTOMREQUEST => 'PUT' , ) ) ; break ; default : $ this -> logger -> error ( "Unknown verb {$httpVerb}" ) ; return false ; } $ result = curl_exec ( $ ch ) ; if ( $ result ) { $ this -> logCommunication ( $ result , 'resp' , $ communicationId ) ; } elseif ( ! is_null ( $ this -> logger ) ) { $ this -> logger -> error ( "Curl failed with (" . curl_errno ( $ ch ) . ") " . curl_error ( $ ch ) ) ; } return $ result ; }
Send a JSON to the API and returns whatever is to return

@param string $json
@param string $httpVerb POST default, or PUT/DELETE/GET
@return mixed <b>TRUE</b> on success or <b>FALSE</b> on failure. However, if the <b>CURLOPT_RETURNTRANSFER</b>
option is set, it will return
the result on success, <b>FALSE</b> on failure.
Send a JSON to the API and returns whatever is to return