本文整理汇总了PHP中Varien_Http_Client::setHeaders方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Http_Client::setHeaders方法的具体用法?PHP Varien_Http_Client::setHeaders怎么用?PHP Varien_Http_Client::setHeaders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Http_Client
的用法示例。
在下文中一共展示了Varien_Http_Client::setHeaders方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getClient
/**
* Client GET call
*
* @param $string, $string
* @return Varien_Http_Client $response
*/
private function getClient($apiKey, $url)
{
$client = new Varien_Http_Client($url);
$client->setMethod(Varien_Http_Client::GET);
$client->setHeaders('Authorization', 'Token token="' . $apiKey . '"');
return $client;
}
示例2: request
/**
* @param array $data Array of each installed Fontis extensions version
* @return string
* @throws Exception
*/
public function request($data)
{
$client = new Varien_Http_Client(Mage::helper('fontis_info')->getInfoUrl(), array('keepalive' => true));
$client->setParameterPost('data', $data);
// If we accept gzip encoding and the response isn't actually chunked, Zend_Http_Response will throw
// an exception. Unfortunately, this means we can't use gzip encoded responses at this time.
$client->setHeaders('Accept-encoding', 'identity');
$response = $client->request(Varien_Http_Client::POST);
if ($response->isError()) {
// if the request fails, throw an exception
throw new Exception('Error getting info data: ' . $response->getStatus() . ' ' . $response->getMessage());
}
return $response->getBody();
}
示例3: _getTransactionDetails
/**
* This function returns full transaction details for a specified transaction ID.
*
* @link http://www.authorize.net/support/ReportingGuide_XML.pdf
* @link http://developer.authorize.net/api/transaction_details/
* @param string $transactionId
* @return Varien_Object
*/
protected function _getTransactionDetails($transactionId)
{
$requestBody = sprintf('<?xml version="1.0" encoding="utf-8"?>' . '<getTransactionDetailsRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">' . '<merchantAuthentication><name>%s</name><transactionKey>%s</transactionKey></merchantAuthentication>' . '<transId>%s</transId>' . '</getTransactionDetailsRequest>', $this->getConfigData('login'), $this->getConfigData('trans_key'), $transactionId);
$client = new Varien_Http_Client();
$uri = $this->getConfigData('cgi_url_td');
$client->setUri($uri ? $uri : self::CGI_URL_TD);
$client->setConfig(array('timeout' => 45));
$client->setHeaders(array('Content-Type: text/xml'));
$client->setMethod(Zend_Http_Client::POST);
$client->setRawData($requestBody);
$debugData = array('request' => $requestBody);
try {
$responseBody = $client->request()->getBody();
$debugData['result'] = $responseBody;
$this->_debug($debugData);
libxml_use_internal_errors(true);
$responseXmlDocument = new Varien_Simplexml_Element($responseBody);
libxml_use_internal_errors(false);
} catch (Exception $e) {
Mage::throwException(Mage::helper('paygate')->__('Payment updating error.'));
}
$response = new Varien_Object();
$response->setResponseCode((string) $responseXmlDocument->transaction->responseCode)->setResponseReasonCode((string) $responseXmlDocument->transaction->responseReasonCode);
return $response;
}
示例4: postData
public function postData($json, $endpoint)
{
$apiURL = Mage::getStoreConfig('settings/endpoint_url') . '/' . $endpoint;
$appID = Mage::getStoreConfig('reachly_handleevent_options/section_one/field_app_id');
$secretKey = Mage::getStoreConfig('reachly_handleevent_options/section_one/field_secret_key');
$auth = $appID . ":" . base64_encode(hash_hmac('sha256', $json, $secretKey));
$client = new Varien_Http_Client();
$client->setUri($apiURL)->setMethod('POST')->setConfig(array('maxredirects' => 0, 'timeout' => 15));
$client->setHeaders(array('Content-Length: ' . strlen($json), 'Authorization: ' . $auth));
$client->setRawData($json, "application/json;charset=UTF-8");
$reqCounter = 0;
do {
$success = true;
try {
$response = $client->request();
} catch (Zend_Http_Client_Exception $e) {
$success = false;
$reqCounter++;
}
} while (!$success && $reqCounter < 3);
}
示例5: rpxCall
private function rpxCall($url, $method = 'GET', $postParams = null)
{
$result = "rpxCallUrl: no result yet";
try {
$http = new Varien_Http_Client($url);
$http->setHeaders(array("Accept-encoding" => "identity"));
if ($method == 'POST') {
$http->setParameterPost($postParams);
}
$response = $http->request($method);
$body = $response->getBody();
try {
$result = json_decode($body);
} catch (Exception $e) {
throw Mage::exception('Mage_Core', $e);
}
if ($result) {
return $result;
} else {
throw Mage::exception('Mage_Core', "something went wrong");
}
} catch (Exception $e) {
throw Mage::exception('Mage_Core', $e);
}
}
示例6: request
/**
* Send the HTTP request and return an HTTP response object
*
* @param string $url
* @param Varien_Object $data
* @param string $method
* @return Varien_Object
*/
public function request($url, Varien_Object $data, $method = 'GET')
{
$client = new Varien_Http_Client($url, array('timeout' => 30));
$client->setMethod($method);
$client->setHeaders('Accept-Encoding: identity');
if ($method == Zend_Http_Client::POST) {
$client->setParameterPost($this->_parseArray($data));
} else {
$client->setParameterGet($this->_parseArray($data));
}
$response = $client->request();
$body = json_decode($response->getBody(), true);
$result = $this->_parseObject($body);
return $result;
}