コード例 #1
0
 /**
  * Rest api 'GET' call (Curl lib)
  * function overriden
  * @author Mustafa Zeynel Dağlı
  * @version 0.2
  * @todo conside check if request is ssl encypted (https)
  */
 public function restApiDefaultCall()
 {
     /* $encrypt = new \vendor\Encrypt\EncryptManual('test');
        $encryptValue = $encrypt->encrypt_times(4, 'kullanici:sifre');
        //print_r('--'.$encryptValue.'--');
        $decryptValue = $encrypt->decrypt_times(4, $encryptValue);
        //print_r('??'.$decryptValue.'??'); */
     $this->servicePkRequired();
     $this->servicePkTempRequired();
     $this->serviceCpkRequired();
     $this->setEncryptClass();
     $params = null;
     $params = $this->getRequestParams();
     /**
      * controlling public key if public key is necessary for this service and
      * public key not found forwarder is in effect then making forward
      * @since version 0.3 06/01/2016
      */
     if (!isset($params['pk']) || $params['pk'] == null) {
         $this->publicKeyNotFoundRedirect();
     }
     /**
      * controlling public temp key if public key is necessary for this service and
      * public temp key not found forwarder is in effect then making forward
      * @since version 0.3 27/01/2016
      */
     if (!isset($params['pktemp']) || $params['pktemp'] == null) {
         $this->publicKeyTempNotFoundRedirect();
     }
     /**
      * controlling company public key if company public key is necessary for this service and
      * public temp key not found forwarder is in effect then making forward
      * @since version 0.3 27/01/2016
      */
     if (!isset($params['cpk']) || $params['cpk'] == null) {
         $this->publicKeyCompanyNotFoundRedirect();
     }
     /**
      * getting public key if user registered    
      * @author Mustafa Zeynel Dağlı
      * @since 06/01/2016 version 0.3
      */
     if (isset($params['pk']) && $this->isServicePkRequired) {
         $resultSet = $this->dalObject->pkIsThere(array('pk' => $params['pk']));
         if (!isset($resultSet['resultSet'][0]['?column?'])) {
             $this->userNotRegisteredRedirect();
         }
     }
     /**
      * company public  key processes wrapper
      * @author Mustafa Zeynel Dağlı
      * @since 0.3 09/06/2016
      * @todo after detail tests code description will be removed
      */
     $this->publicCompanyKeyProcessControler($params);
     /**
      * public  key processes wrapper
      * @author Mustafa Zeynel Dağlı
      * @since 0.3 27/01/2016
      * @todo after detail tests code description will be removed
      */
     $this->publicKeyProcessControler($params);
     /**
      * public temp key processes wrapper
      * @author Mustafa Zeynel Dağlı
      * @since 0.3 27/01/2016
      * @todo after detail tests code description will be removed
      */
     $this->publicKeyTempProcessControler($params);
     $preparedParams = $this->prepareGetParams();
     //$preparedParams = $this->prepareGetParams('', array('pk'));
     if (($ch = @curl_init()) == false) {
         header("HTTP/1.1 500", true, 500);
         die("Cannot initialize CURL session. Is CURL enabled for your PHP installation?");
     }
     //print_r($this->restApiFullPathUrl.'?'.$preparedParams);
     curl_setopt($ch, CURLOPT_URL, $this->restApiFullPathUrl . '?' . $preparedParams);
     //Url together with parameters
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     //Return data instead printing directly in Browser
     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->getCallTimeOut());
     //Timeout (Default 7 seconds)
     /**
      * wrapper for curl header for public key and more
      * @author Mustafa Zeynel Dağlı
      * @since 0.3 27/01/2016
      * @todo after detail tests code description will be removed
      */
     $headerForPublicKeyArr = $this->setCurlHeaderForPublicKey($ch);
     /**
      * wrapper for curl header for public key and more
      * @author Mustafa Zeynel Dağlı
      * @since 0.3 27/01/2016
      * @todo after detail tests code description will be removed
      */
     $headerForPublicKeyTempArr = $this->setCurlHeaderForPublicKeyTemp($ch);
     $curlHeaderArr = array_merge($headerForPublicKeyArr, $headerForPublicKeyTempArr);
     $headerForLogArr = $this->setCurlHeaderForInsertUpdateDelete();
     $curlHeaderArr = array_merge($curlHeaderArr, $headerForLogArr);
     //print_r($headerForLogArr);
     //print_r($curlHeaderArr);
     curl_setopt($ch, CURLOPT_HTTPHEADER, $curlHeaderArr);
     /**
      * if request is ssl encrypted consider header options below
      * @author Mustafa Zeynel Dağlı
      * @since 23/12/2015
      */
     /*curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
       curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);*/
     curl_setopt($ch, CURLOPT_HEADER, 0);
     // we don’t want also to get the header information that we receive.
     //sleep(10);
     $response = curl_exec($ch);
     $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
     if ($response == false) {
         die("curl_exec() failed. Error: " . curl_error($ch));
     }
     return $response;
 }