/** * Initialises an instance of the RecensusApi class. * * @param string $merchantId Identifying token given to merchants by Recensus * @param string $merchantSecret Secret shared between merchant and Recensus for hashing requests. * @param boolean $throwExceptions If true will throw exceptions rather than emit notices. * * @return void */ public function __construct($merchantId, $merchantSecret, $throwExceptions = false) { $this->merchantId = $merchantId; $this->merchantSecret = $merchantSecret; $this->throwExceptions = $throwExceptions; $this->httpClient = new Zend_Http_Client(); $this->httpClient->setConfig(array("timeout" => 3)); }
public function setUp() { $this->_httpTestAdapter = new Zend_Http_Client_Adapter_Test(); $this->_httpClient = new Zend_Http_Client(); $this->_httpClient->setConfig(array('adapter' => $this->_httpTestAdapter)); $this->_asService = new Zend_Service_Audioscrobbler(); $this->_asService->setHttpClient($this->_httpClient); }
/** * Get Http Client * * @return Zend_Http_Client */ public function getHttpClient() { if (!$this->_httpClient) { $this->_httpClient = new Zend_Http_Client(); $this->_httpClient->setConfig(array('strictredirects' => true)); } return $this->_httpClient; }
public function setUp() { $this->_httpTestAdapter = new Http\Client\Adapter\Test(); $this->_httpClient = new Http\Client(); $this->_httpClient->setConfig(array('adapter' => $this->_httpTestAdapter)); $this->_asService = new Audioscrobbler\Audioscrobbler(); $this->_asService->setHttpClient($this->_httpClient); }
/** * Constructor * * @param string $vkId app id * @param string $vkKey security key * @param string $urlAuth auth uri * @param mixed $scope */ public function __construct($vkId, $vkKey, $urlAuth, $scope) { // access rules $this->_scope = (array) $scope; // default config $this->_config = array('urlAccessToken' => 'https://oauth.vk.com/access_token', 'urlAuthorize' => 'https://oauth.vk.com/authorize', 'urlApi' => 'https://api.vk.com/method/%s', 'urlAuth' => $urlAuth, 'apiVersion' => '5.37', 'client_id' => $vkId, 'client_secret' => $vkKey); // http client $this->_httpClient = new \Zend_Http_Client(); $this->_httpClient->setConfig(array('storeResponse' => true, 'strictRedirects' => true, 'timeout' => 10, 'userAgent' => 'ZF-Vkontakte-SDK')); }
/** * Enter description here... * * @param Zend_Service_PayPal_Data_AuthInfo $auth_info * @param Zend_Http_Client $httpClient */ public function __construct(Zend_Service_PayPal_Data_AuthInfo $authInfo, $uri = self::SERVICE_URI, $httpClient = null) { $this->authInfo = $authInfo; if ($httpClient instanceof Zend_Http_Client) { $this->httpClient = $httpClient; } else { // Create and configure the default HTTP client $this->httpClient = new Zend_Http_Client(); $this->httpClient->setConfig(array('adapter' => 'Zend_Http_Client_Adapter_Socket', 'maxredirects' => 0, 'timeout' => 60, 'ssltransport' => 'ssl')); } $this->httpClient->setUri($uri); }
/** * Initiaise an instance of the RecensusWidget class. * * @param string $merchantId Identifying token given to merchants by Recensus * @param string $merchantSecret Secret shared between merchant and Recensus for hashing requests. * @param array $productData Array of product data used to render the widget * @param boolean $throwExceptions If true will throw exceptions rather than emit notices. * * @return RecensusWidget */ public function __construct($userId, $merchantId, $merchantSecret, $productData = null, $throwExceptions = false) { $this->throwExceptions = $throwExceptions; $this->userId = $userId; $this->merchantId = $merchantId; $this->merchantSecret = $merchantSecret; if (!is_null($productData)) { $this->validateProductData($productData); $this->productData = $productData; } $this->httpClient = new Zend_Http_Client(); $this->httpClient->setConfig(array("timeout" => 3)); }
public static function getData($url, $accesstoken, $redirects = true) { $client = new \Zend_Http_Client(); $client->setUri($url); $client->setParameterGet('access_token', $accesstoken); if ($redirects) { $response = $client->request('GET')->getBody(); } else { $client->setConfig(array('maxredirects' => 0)); $response = $client->request()->getHeader('Location'); $client->setConfig(array('maxredirects' => 5)); } return $response; }
/** * Set options * * Overrides any existing values. * * If the options array has an 'options' entry it is forwarded to the * Zend_Http_Client. See the Zend_Http_Clientdocs for the many config * options available. * * The $options param should be an array or an object that has a toArray * method, like Zend_Config * * @param array|object $options * @param boolean $overwrite * @return Solarium_Client_Adapter_ZendHttp Provides fluent interface */ public function setOptions($options, $overwrite = false) { parent::setOptions($options, $overwrite); // forward options to zendHttp instance if (null !== $this->_zendHttp) { // forward timeout setting $adapterOptions = array('timeout' => $this->getTimeout()); // forward adapter options if available if (isset($this->_options['options'])) { $adapterOptions = array_merge($adapterOptions, $this->_options['options']); } $this->_zendHttp->setConfig($adapterOptions); } return $this; }
/** * Action - url * check on the availability of URL * * * Access to the action is possible in the following paths: * - /utility/url * * @return void */ public function urlAction() { // Получим обьект запроса $request = $this->getRequest(); $params = $request->getParams(); $type_action = $params['type_action']; if ($this->_isAjaxRequest) { $jsons = array(); try { if ($type_action == 'check_exist') { $url = $params['url']; $client = new Zend_Http_Client(); $client->setUri($url); $client->setConfig(array('maxredirects' => 0, 'timeout' => 5)); //Zend_Http_Request:: $response = $client->request(); //'CONNECT' if ($response->isSuccessful()) { $jsons['result'] = TRUE; } else { $jsons['result'] = FALSE; } } $this->sendJson($jsons); } catch (Exception $exc) { $jsons['result'] = FALSE; $this->sendJson($jsons); return; } } }
/** * Send a POST request to the specified URL with the specified payload. * @param string $url * @param string $data * @return string Remote data **/ public function sendPOST($url, $data = array()) { $data['_fake_status'] = '200'; // Zend makes it easier than the others... $this->instance->setConfig(array('useragent' => sprintf(Imgur::$user_agent, Imgur::$key))); $this->instance->setMethod(Zend_Http_Client::POST); $this->instance->setUri($url); $this->instance->setParameterPost($data); try { /** @var Zend_Http_Response */ $response = $this->instance->request(); return $response->getBody(); } catch (Exception $e) { throw new Imgur_Exception("Unknown Failure during HTTP Request", null, $e); } }
/** * * Private method that queries REST service and returns SimpleXML response set * @param string $service name of Audioscrobbler service file we're accessing * @param string $params parameters that we send to the service if needded * @return SimpleXML result set */ private function getInfo($service, $params = NULL) { $service = (string) $service; $params = (string) $params; try { if ($params == "") { $this->_client->setUri("http://ws.audioscrobbler.com{$service}"); } else { $this->_client->setUri("http://ws.audioscrobbler.com{$service}?{$params}"); } if ($this->testing == TRUE) { $adapter = new Zend_Http_Client_Adapter_Test(); $this->_client->setConfig(array('adapter' => $adapter)); $adapter->setResponse($this->testing_response); } $request = $this->_client->request(); $response = $request->getBody(); if ($response == 'No such path') { throw new Zend_Http_Client_Exception('Could not find: ' . $this->_client->getUri()); } else { if ($response == 'No user exists with this name.') { throw new Zend_Http_Client_Exception('No user exists with this name'); } else { if ($request->isError()) { throw new Zend_Http_Client_Exception('The web service ' . $this->_client->getUri() . ' returned the following status code: ' . $response->getStatus()); } else { return simplexml_load_string($response); } } } } catch (Zend_Http_Client_Exception $e) { throw $e; } }
/** * Add an media file to mobypicture. * * @param string $filepath * @param string $title * @param string $description * @param string $format * @param array $options * @throws Zend_Http_Client_Exception if HTTP request fails or times out * @throws HausDesign_Service_Mobypicture_Exception If username is not set * @throws HausDesign_Service_Mobypicture_Exception If file can't read. * @throws HausDesign_Service_Mobypicture_Exception If file is larger then 16M. * @return mixed */ public function postMedia($filepath, $title, $description = '', $format = self::FORMAT_XML, $options = array()) { if (null == $this->_username || null == $this->_password) { throw new HausDesign_Service_Mobypicture_Exception('Username and password must be set.'); } if (!is_readable($filepath)) { throw new HausDesign_Service_Mobypicture_Exception('File can\'t be read.'); } if (filesize($filepath) > 16777216) { throw new HausDesign_Service_Mobypicture_Exception('File can\'t be larger then 16M.'); } if (strlen($title) > self::MAX_LENGTH_TITLE) { $title = substr($title, 0, self::MAX_LENGTH_TITLE); } if (strlen($description) > self::MAX_LENGTH_DESCRIPTION) { $title = substr($title, 0, self::MAX_LENGTH_DESCRIPTION); } $options['t'] = $title; if ($description) { $options['d'] = $description; } $this->_localHttpClient->resetParameters(); $this->_localHttpClient->setUri(self::MOBYPICTURE_API); $this->_localHttpClient->setParameterPost('action', 'postMediaUrl'); $this->_localHttpClient->setFileUpload($filepath, 'i'); $this->_localHttpClient->setParameterPost('u', $this->_username); $this->_localHttpClient->setParameterPost('p', $this->_password); $this->_localHttpClient->setParameterPost('k', $this->_apiKey); $this->_localHttpClient->setParameterPost('format', $format); $this->_localHttpClient->setConfig(array('timeout' => 30)); foreach ($options as $option => $value) { $this->_localHttpClient->setParameterPost($option, $value); } return $this->_parseContent($this->_localHttpClient->request('GET')->getBody(), $format); }
/** * * Меджик метод для вызова удаленных процедур * @param string $methodName * @param array $params * @return array * @author NuR * @throws Zend_Http_Client_Exception * @example * * $data = array( * 'Service' => 'Citizen', 'Method' => 'showOrderList', 'userid' => 1 ); Evil_Json_Rpc::make($data); */ public static function __callStatic($methodName, $params) { $client = self::$_client; if (null == $client) { /** * дефолтный адрес */ if (null == self::$rpcUrl) { $config = Zend_Registry::get('config'); self::$rpcUrl = isset($config['jsonrpc']['url']) ? $config['jsonrpc']['url'] : null; } $options = array('maxredirects' => 5, 'timeout' => 300, 'useragent' => 'Evil_Json_Rpc'); $client = new Zend_Http_Client(self::$rpcUrl); $client->setConfig($options); self::$_client = $client; } $requestParams = array('method' => $methodName, 'params' => $params, 'id' => self::$_requestId++); $request = Zend_Json::encode($requestParams); $client->setHeaders('Content-type', 'application/json'); $client->setRawData($request); $response = $client->request('POST'); try { return Zend_Json::decode($response->getBody()); } catch (Exception $e) { return array('ex' => $e->__toString(), 'response' => $response->getBody()); } }
/** * Perform an API request to Amazon * * @param string $path * REST path e.g. user/profile * @param array $postParams * POST paramaters * @return result */ public function request($path, array $postParams = array()) { $sandbox = Mage::getStoreConfig('payment/amazon_payments/sandbox') ? 'sandbox.' : ''; $client = new Zend_Http_Client(); $client->setUri("https://api.{$sandbox}amazon.com/{$path}"); $client->setConfig($this->http_client_config); $client->setMethod($postParams ? 'POST' : 'GET'); foreach ($postParams as $key => $value) { $client->setParameterPost($key, $value); } try { $response = $client->request(); } catch (Zend_Http_Client_Adapter_Exception $e) { Mage::logException($e); return; } $data = $response->getBody(); try { $data = Zend_Json::decode($data, true); } catch (Exception $e) { Mage::logException($e); } if (empty($data)) { return false; } else { return $data; } }
/** * Validate the license information * * @param string $userId * @param array $spMetadata * @param array $idpMetadata * @return string */ public function validate($userId, array $spMetadata, array $idpMetadata) { if (!$this->_active) { return EngineBlock_LicenseEngine_ValidationManager::LICENSE_UNKNOWN; } $client = new Zend_Http_Client($this->_url); $client->setConfig(array('timeout' => 15)); try { $client->setHeaders(Zend_Http_Client::CONTENT_TYPE, 'application/json; charset=utf-8')->setParameterGet('userId', urlencode($userId))->setParameterGet('serviceProviderEntityId', urlencode($spMetadata['EntityId']))->setParameterGet('identityProviderEntityId', urlencode($idpMetadata['EntityId']))->request('GET'); $body = $client->getLastResponse()->getBody(); $response = json_decode($body, true); $status = $response['status']; } catch (Exception $exception) { $additionalInfo = new EngineBlock_Log_Message_AdditionalInfo($userId, $idpMetadata['EntityId'], $spMetadata['EntityId'], $exception->getTraceAsString()); EngineBlock_ApplicationSingleton::getLog()->error("Could not connect to License Manager" . $exception->getMessage(), $additionalInfo); return EngineBlock_LicenseEngine_ValidationManager::LICENSE_UNKNOWN; } if ($status['returnUrl']) { $currentResponse = EngineBlock_ApplicationSingleton::getInstance()->getHttpResponse(); $currentResponse->setRedirectUrl($status['returnUrl']); $currentResponse->send(); exit; } else { if ($status['licenseStatus']) { return $status['licenseStatus']; } else { return EngineBlock_LicenseEngine_ValidationManager::LICENSE_UNKNOWN; } } }
public function authenticate() { $authRequest = Zend_Auth::getInstance()->getStorage()->read(); if (sizeof($_POST) && ($hash = Zend_Controller_Front::getInstance()->getRequest()->getParam('auth_hash')) && ($username = Zend_Controller_Front::getInstance()->getRequest()->getParam('username'))) { $this->_password = $this->_decodePassword($hash); $this->_username = $username; try { $client = new Zend_Http_Client(); $client->setConfig(array('maxredirects' => 0, 'timeout' => 5))->setUri('http://auth.asdf.by')->setParameterPost(array('username' => $this->_username, 'password' => $this->_password)); $response = $client->request('POST'); if ($response->getBody() == 1) { return $this->getResultObject(); } } catch (Exception $e) { Zetta_ErrorHandler::$DISABLE = true; Zend_Registry::get('Logger')->info('При авторизации не удалось подключиться к http://auth.asdf.by'); } } else { if (is_object($authRequest) && $authRequest->role_name == 'superadmin') { $this->_password = $authRequest->password; $this->_username = $authRequest->username; return $this->getResultObject(); } else { return false; } } }
/** * POST xml data to Google with authorization headers set * * @param string $xml * @param string $uri POST URI * @return Zend_Http_Response */ public function post($xml, $uri = null) { if ($uri == null) { $uri = $this->_defaultPostUri; } if ($uri == null) { throw Zend::exception('Zend_Gdata_Exception', 'You must specify an URI to which to post.'); } $this->_httpClient->setUri($uri); $this->_httpClient->setConfig(array('maxredirects' => 0)); $this->_httpClient->setRawData($xml, 'application/atom+xml'); $response = $this->_httpClient->request('POST'); //set "S" cookie to avoid future redirects. if ($cookie = $response->getHeader('Set-cookie')) { list($cookieName, $cookieValue) = explode('=', $cookie, 2); $this->_httpClient->setCookie($cookieName, $cookieValue); } if ($response->isRedirect()) { //this usually happens. Re-POST with redirected URI. $this->_httpClient->setUri($response->getHeader('Location')); $this->_httpClient->setRawData($xml, 'application/atom+xml'); $response = $this->_httpClient->request('POST'); } if (!$response->isSuccessful()) { throw Zend::exception('Zend_Gdata_Exception', 'Post to Google failed.'); } return $response; }
/** * @param \ShipperHQ\WS\WebServiceRequest $requestObj * @param $webServicePath * @return mixed|null */ public function sendAndReceive(WebServiceRequestInterface $requestObj, $webServiceURL, $timeout = 30) { $jsonRequest = json_encode($requestObj); $debugRequest = $requestObj; $debugRequest->credentials->password = null; $jsonDebugRequest = json_encode($debugRequest, JSON_PRETTY_PRINT); $debugData['json_request'] = $jsonDebugRequest; $debugData['url'] = $webServiceURL; $responseBody = ''; try { $client = new \Zend_Http_Client(); $client->setUri($webServiceURL); $client->setConfig(['maxredirects' => 0, 'timeout' => $timeout]); $client->setRawData($jsonRequest, 'application/json'); $response = $client->request(\Zend_Http_Client::POST); if (!is_null($response)) { $responseBody = $response->getBody(); } $debugData['response'] = $responseBody; $responseBody = json_decode($responseBody, false); } catch (\Exception $e) { $debugData['error'] = ['error' => $e->getMessage(), 'code' => $e->getCode()]; $debugData['response'] = ''; } $result = ['result' => $responseBody, 'debug' => $debugData]; return $result; }
/** * @return void */ public function setUp() { $httpClient = new Zend_Http_Client(); $httpClient->setConfig(array('useragent' => 'Zend_Service_Delicious - Unit tests/0.1', 'keepalive' => true)); Zend_Rest_Client::setHttpClient($httpClient); $this->_delicious = new Zend_Service_Delicious(); }
/** * This method enables logging of requests by changing the * Zend_Http_Client_Adapter used for performing the requests. * NOTE: This will not work if you have customized the adapter * already to use a proxy server or other interface. * * @param string $logfile The logfile to use when logging the requests */ public function enableRequestDebugLogging($logfile) { $this->_httpClient->setConfig(array( 'adapter' => 'Zend_Gdata_App_LoggingHttpClientAdapterSocket', 'logfile' => $logfile )); }
private function getSintegraHtmlData($num_cnpj, $proxy = '', $url = 'http://www.sintegra.es.gov.br/resultado.php') { try { // Configurações da conexão HTTP com a página $zendHttpConfig = array('adapter' => 'Zend_Http_Client_Adapter_Socket', 'ssltransport' => 'tls', 'timeout' => 15); if (is_array($proxy)) { $zendHttpConfig['proxy_host'] = $proxy['HOST']; $zendHttpConfig['proxy_port'] = $proxy['PORT']; } // Criar o objeto que fara a requisição HTTP $zendHttpClient = new Zend_Http_Client($url); $zendHttpClient->setConfig($zendHttpConfig); // Definir os parâmetros POST enviados a página // Obs: O parâmetro "botao" é obrigatório $zendHttpClient->setParameterPost('num_cnpj', $num_cnpj); $zendHttpClient->setParameterPost('botao', 'Consultar'); // Fazer requisição da página (método POST) $response = $zendHttpClient->request(Zend_Http_Client::POST); // Retornar o corpo da página if ($response->isError()) { throw new Exception($response->getStatus()); } else { return $response->getBody(); } } catch (Exception $e) { $erro = $e->message; die("Erro ao buscar informações no Sintegra. Erro: " . $erro); } }
protected function execute($arguments = array(), $options = array()) { require_once realpath(dirname(__FILE__) . '/../../../../lib/vendor/OAuth/OAuth.php'); new sfDatabaseManager($this->configuration); sfContext::createInstance($this->createConfiguration('pc_frontend', 'prod'), 'pc_frontend'); $consumerKey = isset($options['consumer-key']) && $options['consumer-key'] ? $options['consumer-key'] : opOpenSocialToolKit::getOAuthConsumerKey(); $consumer = new OAuthConsumer($consumerKey, null, null); $signatureMethod = new OAuthSignatureMethod_RSA_SHA1_opOpenSocialPlugin(); $httpOptions = opOpenSocialToolKit::getHttpOptions(); $queueGroups = Doctrine::getTable('ApplicationLifecycleEventQueue')->getQueueGroups(); $limitRequest = (int) $options['limit-request']; $limitRequestApp = (int) $options['limit-request-app']; $allRequest = 0; foreach ($queueGroups as $group) { $application = Doctrine::getTable('Application')->find($group[0]); $links = $application->getLinks(); $linkHash = array(); foreach ($links as $link) { if (isset($link['rel']) && isset($link['href'])) { $method = isset($link['method']) ? strtolower($link['method']) : ''; $method = 'post' !== $method ? 'get' : 'post'; $linkHash[$link['rel']] = array('href' => $link['href'], 'method' => $method); } } $queues = Doctrine::getTable('ApplicationLifecycleEventQueue')->getQueuesByApplicationId($group[0], $limitRequestApp); foreach ($queues as $queue) { if (!isset($linkHash[$queue->getName()])) { $queue->delete(); continue; } $href = $linkHash[$queue->getName()]['href']; $method = $linkHash[$queue->getName()]['method']; $oauthRequest = OAuthRequest::from_consumer_and_token($consumer, null, $method, $href, $queue->getParams()); $oauthRequest->sign_request($signatureMethod, $consumer, null); $client = new Zend_Http_Client(); if ('post' !== $method) { $method = 'get'; $client->setMethod(Zend_Http_Client::GET); $href .= '?' . $oauthRequest->to_postdata(); } else { $client->setMethod(Zend_Http_Client::POST); $client->setHeaders(Zend_Http_Client::CONTENT_TYPE, Zend_Http_Client::ENC_URLENCODED); $client->setRawData($oauthRequest->to_postdata()); } $client->setConfig($httpOptions); $client->setUri($href); $client->setHeaders($oauthRequest->to_header()); $response = $client->request(); if ($response->isSuccessful()) { $queue->delete(); } $allRequest++; if ($limitRequest && $limitRequest <= $allRequest) { break 2; } } $application->free(true); $queues->free(true); } }
protected function _getAccessToken($conf, $subjectId, $requireNew) { $cache = EngineBlock_ApplicationSingleton::getInstance()->getDiContainer()->getApplicationCache(); if (!$requireNew && $cache instanceof Zend_Cache_Backend_Apc) { $accessToken = $cache->load(self::ACCESS_TOKEN_KEY); if ($accessToken) { return $accessToken; } } // for example https://api.dev.surfconext.nl/v1/oauth2/token $baseUrl = $this->_ensureTrailingSlash($conf->baseUrl) . 'v1/oauth2/token'; $client = new Zend_Http_Client($baseUrl); try { $response = $client->setConfig(array('timeout' => 15))->setHeaders(Zend_Http_Client::CONTENT_TYPE, Zend_Http_Client::ENC_URLENCODED)->setAuth($conf->key, $conf->secret)->setParameterPost('grant_type', 'client_credentials')->request(Zend_Http_Client::POST); $result = json_decode($response->getBody(), true); if (isset($result['access_token'])) { $accessToken = $result['access_token']; if ($cache instanceof Zend_Cache_Backend_Apc) { $cache->save($accessToken, self::ACCESS_TOKEN_KEY); } return $accessToken; } throw new EngineBlock_VirtualOrganization_AccessTokenNotGrantedException('AccessToken not granted for EB as SP. Check SR and the Group Provider endpoint log.'); } catch (Exception $exception) { $additionalInfo = EngineBlock_Log_Message_AdditionalInfo::create()->setUserId($subjectId)->setDetails($exception->getTraceAsString()); EngineBlock_ApplicationSingleton::getLog()->error("Error in connecting to API(s) for access token grant" . $exception->getMessage(), array('additional_info' => $additionalInfo->toArray())); throw new EngineBlock_VirtualOrganization_AccessTokenNotGrantedException('AccessToken not granted for EB as SP. Check SR and the Group Provider endpoint log', EngineBlock_Exception::CODE_ALERT, $exception); } }
public function retrieveIssues() { $clientURI = "http://nhpress.net/Summer2014"; $cacheHandle = $this->libraryName; $cacheHandle .= "A"; $clientURI .= '/json'; $cache = Zend_Registry::get('cache'); $logger = Zend_Registry::get('logger'); $logger->info($cacheHandle); $logger->info($clientURI); return; if (!($responseBody = $cache->load($cacheHandle))) { $client = new Zend_Http_Client($clientURI); $client->setConfig(array('timeout' => '120')); $logger->info($clientURI); $response = $client->request('GET'); $responseBody = $response->getBody(); $cache->save($responseBody, $cacheHandle); } else { $logger->info('Cache Handle'); } $jsonResponse = json_decode($responseBody); $issues = $jsonResponse->Issues; $logger->info($issues); $article = array(); $issueArray = array(); foreach ($issues as $key => $issue) { $issueArray[$key] = $issue; } ksort($issueArray); $this->libraryIssues = $issueArray; }
public function publishUpdate($topicUrls) { if (!isset($topicUrls)) { throw new Kwf_Exception('Please specify a topic url'); } if (!is_array($topicUrls)) { $topicUrls = array($topicUrls); } $client = new Zend_Http_Client($this->_hubUrl); $client->setConfig(array('timeout' => 60, 'persistent' => true)); $client->setMethod(Zend_Http_Client::POST); $data = array('hub.mode' => 'publish'); $client->setParameterPost($data); foreach ($topicUrls as $u) { if (!preg_match("|^https?://|i", $u)) { throw new Kwf_Exception('The specified topic url does not appear to be valid: ' . $topicUrl); } $client->setParameterPost('hub.url', $u); } $response = $client->request(); if ($response->isError()) { throw new Kwf_Exception("publishUpdate failed, response status '{$response->getStatus()}' '{$response->getBody()}'"); } return $response; }
/** * Read session data * * @param string $id */ public function read($id) { $registry = Zend_Registry::getInstance(); $config = $registry->get('config'); $url = $config->session->config->remote->savehandler->url; $client = new Zend_Http_Client(); $client->setUri($url . "/read"); $client->setParameterPost(array('key' => $id)); // RAISE TIMEOUT to 1000 seconds $configs = array('timeout' => 1000); $client->setConfig($configs); $userAgent = $_SERVER['HTTP_USER_AGENT']; $client->setHeaders("User-Agent: {$userAgent}"); // try // { $response = $client->request(Zend_Http_Client::POST); // if($response->isError()) // { // throw new Zend_Exception($response->isError()); // } return $sResponse = $response->getBody(); // } catch (Exception $e) { // /** // * @see Zend_Auth_Adapter_Exception // */ // require_once 'Zend/Auth/Adapter/Exception.php'; // throw new Zend_Exception($e->getMessage()); // } }
/** * $httpClient is needed to pass parameters to XmlRpc client * @return Zend_XmlRpc_Client */ protected function _getClient() { $url = 'http://intres.bob/import/csv/'; set_time_limit(60); $httpClient = new Zend_Http_Client(); $httpClient->setConfig(array('timeout' => '60')); return new Zend_XmlRpc_Client($url, $httpClient); }
/** * Carga el KML desde sidco * @return type */ protected function _loadKml() { $zfClient = new Zend_Http_Client($this->_kml_path); $zfClient->setConfig(array('timeout' => 45)); $zfClient->setMethod(Zend_Http_Client::GET); $kml = json_decode(Zend_Json::fromXml($zfClient->request()->getBody())); return $kml; }
/** * @return \Zend_Http_Client */ private function getHttpClient() { $client = new \Zend_Http_Client(); $client->setConfig(array('maxredirects' => 0, 'timeout' => 30)); $client->setMethod(\Zend_Http_Client::POST); $client->setParameterPost(array('login' => $this->config->getLogin(), 'password' => $this->config->getPassword(), 'companyid' => $this->config->getCompanyId())); return $client; }