public function retrieve($id, $params = null) { $requestor = new Pingpp_ApiRequestor($this->_apiKey); $base = $this['url']; $id = Pingpp_ApiRequestor::utf8($id); $extn = urlencode($id); list($response, $apiKey) = $requestor->request('get', "{$base}/{$extn}", $params); return Pingpp_Util::convertToPingppObject($response, $apiKey); }
public function __toStdObject() { return Pingpp_Util::convertPingppObjectToStdObject($this->_values); }
protected static function _scopedCreate($class, $params = null, $apiKey = null) { self::_validateCall('create', $params, $apiKey); $requestor = new Pingpp_ApiRequestor($apiKey); $url = self::_scopedLsb($class, 'classUrl', $class); list($response, $apiKey) = $requestor->request('post', $url, $params); return Pingpp_Util::convertToPingppObject($response, $apiKey); }
private function _requestRaw($method, $url, $params) { $myApiKey = $this->_apiKey; if (!$myApiKey) { $myApiKey = Pingpp::$apiKey; } if (!$myApiKey) { $msg = 'No API key provided. (HINT: set your API key using ' . '"Pingpp::setApiKey(<API-KEY>)". You can generate API keys from ' . 'the Pingpp web interface. See https://pingxx.com/document/api for ' . 'details, or email support@pingxx.com if you have any questions.'; throw new Pingpp_AuthenticationError($msg); } $absUrl = $this->apiUrl($url); $params = self::_encodeObjects($params, $method == 'post'); $langVersion = phpversion(); $uname = php_uname(); $ua = array('bindings_version' => Pingpp::VERSION, 'lang' => 'php', 'lang_version' => $langVersion, 'publisher' => 'pingplusplus', 'uname' => $uname); $headers = array('X-Pingpp-Client-User-Agent: ' . json_encode($ua), 'User-Agent: Pingpp/v1 PhpBindings/' . Pingpp::VERSION, 'Authorization: Bearer ' . $myApiKey); if (Pingpp::$apiVersion) { $headers[] = 'Pingplusplus-Version: ' . Pingpp::$apiVersion; } if ($method == 'post') { $headers[] = 'Content-type: application/json;charset=UTF-8'; } $requestHeaders = Pingpp_Util::getRequestHeaders(); if (isset($requestHeaders['Pingpp-Sdk-Version'])) { $headers[] = 'Pingpp-Sdk-Version: ' . $requestHeaders['Pingpp-Sdk-Version']; } if (isset($requestHeaders['Pingpp-One-Version'])) { $headers[] = 'Pingpp-One-Version: ' . $requestHeaders['Pingpp-One-Version']; } list($rbody, $rcode) = $this->_curlRequest($method, $absUrl, $headers, $params); return array($rbody, $rcode, $myApiKey); }