/** * @param string $service service * @param array $parameters parameters * @param string $endpoint endpoint * * @return \SimpleXMLElement */ public function call($service = null, array $parameters = array(), $endpoint = null) { if (null === $endpoint) { $endpoint = $this->metadata->getEndpoint(); } $default = array('api_key' => $this->metadata->getApiKey(), 'format' => 'json'); if ($service) { $default['method'] = $service; } $parameters = array_merge($default, $parameters); $parameters = array_filter($parameters, function ($value) { return null !== $value; }); $parameters['api_sig'] = $this->buildSignature($parameters); $this->addOAuthParameters($endpoint, $parameters); return $this->http->post($endpoint, $parameters); }
/** * @param string $service * @param array $parameters * @param string $endpoint * * @return array */ private function buildParams($service, array $parameters, &$endpoint) { if (null === $endpoint) { $endpoint = $this->metadata->getEndpoint(); } $default = array('api_key' => $this->metadata->getApiKey(), 'format' => 'rest'); if ($service) { $default['method'] = $service; } $parameters = array_merge($default, $parameters); $parameters = array_filter($parameters, function ($value) { return null !== $value; }); $parameters['api_sig'] = $this->buildSignature($parameters); $this->addOAuthParameters($endpoint, $parameters); return $parameters; }