Пример #1
0
 /**
  * Print debug message
  *
  * @param   string $str Debug message
  * @param   array $args (Optional) Value to dump
  * @static
  * @access  public
  * @return  void
  */
 public static function p($str, $args = false)
 {
     if (self::$_debug === true || ApiConfig::get('debug') === true) {
         // first call
         if (self::$_debug === false) {
             self::$_debug = true;
         }
         if ($args !== false) {
             $str .= ', dump: ' . var_export($args, true);
         }
         $str .= ".\n";
         print_r('> ' . $str);
     }
 }
Пример #2
0
 /**
  * Get OAuth instance
  *
  * @param   integer $authType Auth type
  * @access  protected
  * @return  object
  */
 protected function _getOAuthInstance($authType)
 {
     ApiDebug::p('get OAuth instance');
     $oauth = new \OAuth(self::$_apiKey, self::$_secret, self::$_sigMethod, $authType);
     if (ApiConfig::get('debug')) {
         $oauth->enableDebug();
     }
     if (!self::$_verifySsl) {
         $oauth->disableSSLChecks();
     }
     return $oauth;
 }
Пример #3
0
 /**
  * Run API request
  *
  * @param   string $type Type of request, i.e. method
  * @param   string $url URL
  * @param   array $params (Optional) Additional list of parameters
  * @access  protected
  * @return  array
  */
 protected function _request($type, $url, $params = array())
 {
     ApiDebug::p('running Client request', $this->_server);
     $method = 'POST';
     switch ($type) {
         case 'PUT':
             $params['http_method'] = 'put';
             break;
         case 'DELETE':
             $params['http_method'] = 'delete';
             break;
         case 'GET':
             $method = 'GET';
             break;
         default:
             break;
     }
     if (self::$_epoint == UPWORK_API_EP_NAME) {
         $url = $url . '.' . self::DATA_FORMAT;
     } elseif (self::$_epoint == UPWORK_GDS_EP_NAME) {
         $params['tqx'] = 'out:' . self::DATA_FORMAT;
     }
     $this->_server->option('sigMethod', ApiConfig::get('sigMethod'));
     $this->_server->option('epoint', self::$_epoint);
     $response = $this->_server->request($method, $url, $params);
     return json_decode($response);
 }