本文整理匯總了PHP中Am_HttpRequest::setHeader方法的典型用法代碼示例。如果您正苦於以下問題:PHP Am_HttpRequest::setHeader方法的具體用法?PHP Am_HttpRequest::setHeader怎麽用?PHP Am_HttpRequest::setHeader使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Am_HttpRequest
的用法示例。
在下文中一共展示了Am_HttpRequest::setHeader方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: _doBill
public function _doBill(Invoice $invoice, $doFirst, CcRecord $cc, Am_Paysystem_Result $result)
{
$xml = new SimpleXMLElement('<ewaygateway></ewaygateway>');
$xml->ewayCustomerID = $this->getConfig('customer_id');
$xml->ewayTotalAmount = $doFirst ? $invoice->first_total * 100 : $invoice->second_total * 100;
$xml->ewayCustomerFirstName = $cc->cc_name_f;
$xml->ewayCustomerLastName = $cc->cc_name_l;
$xml->ewayCustomerEmail = $invoice->getUser()->email;
$xml->ewayCustomerAddress = $cc->cc_street;
$xml->ewayCustomerPostcode = $cc->cc_zip;
$xml->ewayCustomerInvoiceDescription = $invoice->getLineDescription();
$xml->ewayCustomerInvoiceRef = $invoice->public_id;
$xml->ewayCardHoldersName = sprintf('%s %s', $cc->cc_name_f, $cc->cc_name_l);
$xml->ewayCardNumber = $cc->cc_number;
$xml->ewayCardExpiryMonth = $cc->getExpire('%1$02d');
$xml->ewayCardExpiryYear = $cc->getExpire('%2$02d');
$xml->ewayTrxnNumber = $invoice->public_id;
$xml->ewayOption1 = '';
$xml->ewayOption2 = '';
$xml->ewayOption3 = '';
$xml->ewayCVN = $cc->getCvv();
$request = new Am_HttpRequest($this->getGateway(), Am_HttpRequest::METHOD_POST);
$request->setBody($xml->asXML());
$request->setHeader('Content-type', 'text/xml');
$tr = new Am_Paysystem_Transaction_CreditCard_Eway($this, $invoice, $request, $doFirst);
$tr->run($result);
}
示例2: directAction
public function directAction(Am_Request $request, Zend_Controller_Response_Http $response, array $invokeArgs)
{
if ($request->getActionName() == 'api' && ($api_resend = $this->getConfig('api_resend'))) {
try {
$client = new Am_HttpRequest($api_resend, Am_HttpRequest::METHOD_POST);
$client->setHeader('Content-type', 'text/xml');
$client->setBody($request->getRawBody());
$response = $client->send();
} catch (Exception $e) {
$this->getDi()->errorLogTable->logException($e);
}
}
parent::directAction($request, $response, $invokeArgs);
}
示例3: _process
public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
{
$xml = new SimpleXMLElement('<request/>');
$transactiondetails = $xml->addChild('transactiondetails');
$transactiondetails->addChild('merchantcode', $this->getConfig('merchantid'));
$transactiondetails->addChild('merchantpwd', $this->getConfig('merchantpwd'));
$transactiondetails->addChild('trackid', $invoice->public_id);
$transactiondetails->addChild('customerip', $request->getClientIp());
$transactiondetails->addChild('udf1', $invoice->public_id);
$transactiondetails->addChild('customerid', $invoice->getLogin());
$paymentdetails = $xml->addChild('paymentdetails');
$paymentdetails->addChild('paysource', 'enets');
$paymentdetails->addChild('amount', $invoice->first_total);
$paymentdetails->addChild('currency', $invoice->currency);
$paymentdetails->addChild('actioncode', 1);
$notificationurls = $xml->addChild('notificationurls');
$notificationurls->addChild('successurl', $this->getReturnUrl());
$notificationurls->addChild('failurl', $this->getCancelUrl());
$shippingdetails = $xml->addChild('shippingdetails');
foreach (array('ship_address' => $invoice->getStreet(), 'ship_email' => $invoice->getEmail(), 'ship_postal' => $invoice->getZip(), 'ship_address2' => $invoice->getStreet1(), 'ship_city' => $invoice->getCity(), 'ship_state' => $invoice->getState(), 'ship_phone' => $invoice->getPhone(), 'ship_country' => $invoice->getCountry()) as $k => $v) {
$shippingdetails->addChild($k, $v);
}
$req = new Am_HttpRequest($this->getConfig('gatewayurl'), Am_HttpRequest::METHOD_POST);
$req->setHeader('Content-type: text/xml; charset=utf-8')->setHeader('Connection:close')->setBody($xml->asXML());
$response = $req->send();
$resxml = @simplexml_load_string($response->getBody());
if (!$resxml instanceof SimpleXMLElement) {
throw new Am_Exception_InputError('Incorrect Gateway response received!');
}
if ($paymenturl = (string) $resxml->transactionresponse->paymenturl) {
$a = new Am_Paysystem_Action_Redirect($paymenturl);
$result->setAction($a);
} else {
throw new Am_Exception_InputError('Incorrect Gateway response received! Got: ' . (string) $resxml->responsedesc);
}
}
示例4: validateSource
public function validateSource()
{
$params = array('preapproval_id' => $this->request->get('preapproval_id'));
$req = new Am_HttpRequest($this->plugin->getUrl() . "/preapproval/", Am_HttpRequest::METHOD_POST);
$req->setBody(json_encode($params));
$req->setHeader("Content-Type", "application/json");
$req->setHeader("Authorization", "Bearer " . $this->plugin->getConfig('token'));
$res = $req->send();
$arr = json_decode($res->getBody(), true);
$this->log->add(var_export($arr, true));
if ($res->getStatus() != 200) {
Am_Di::getInstance()->errorLogTable->log("WEPAY API ERROR : {$arr['error_code']} - {$arr['error_description']}");
return false;
}
if (!empty($arr['error_description'])) {
return false;
}
$this->preapproval = $arr;
return true;
}
示例5: _request
protected function _request($function, $method, $params = null)
{
$this->_request->setUrl(self::API_URL . '/' . $function);
$nonce = sprintf('%0.0f', round(microtime(true) * 1000000));
$data = $nonce . self::API_URL . '/' . $function . http_build_query($params);
$this->_request->setHeader(array('ACCESS_KEY' => $this->_key, 'ACCESS_SIGNATURE' => hash_hmac('sha256', $data, $this->_secret), 'ACCESS_NONCE' => $nonce));
$this->_request->setMethod($method);
if (!empty($params)) {
$this->_request->addPostParameter($params);
}
$resp = $this->_request->send();
if ($resp->getStatus() != 200) {
throw new Am_Exception_InternalError('CoinBase: Status for API request was not 200. Got: ' . $resp->getStatus());
}
$data = json_decode($resp->getBody());
if (is_null($data)) {
throw new Am_Exception_InternalError('CoinBase: Unable to decode response. Got: ' . $resp);
}
if (!@$data->success) {
throw new Am_Exception_InternalError('CoinBase: Not successfull response.Got: ' . print_r($data, true));
}
return $data;
}
示例6: getOrderCategories
private function getOrderCategories()
{
$OrderCategories = array();
$url = $this->getConfig('testing') ? self::TEST_URL : self::URL;
$url .= "list-categories/id/" . $this->getConfig('site_id');
$c = new Am_HttpRequest($url);
$c->setHeader('Accept', 'application/xml');
$res = $c->send();
preg_match_all('/<category id="(\\d+)">(.*)<\\/category>/sU', $res->getBody(), $matches);
foreach ($matches[1] as $k => $v) {
$OrderCategories[$v] = $matches[2][$k];
}
return $OrderCategories;
/*
The order or product categories are attached to, and depend upon, the merchant site’s
category. Depending on the category that is associated with the site, the categories that are
available to the order and products will NOT be the same.
You can obtain the list of order and product category ID’s for the merchant site at this URL:
Live platform : https://payment.hipay.com/order/list-categories/id/[merchant_website_id]
Test platform : https://test-payment.hipay.com/order/list-categories/id/[merchant_website_id]
<mapi>
<categoriesList>
<category id="248">Abonnement</category>
<category id="514">Autres</category>
<category id="118">Télécharegment</category>
</categoriesList>
</mapi>
*/
}
示例7: APIRequest
function APIRequest($type = 'subscription', $function = '', $vars = array())
{
try {
$client = new Am_HttpRequest(sprintf("https://ssl.ditonlinebetalingssystem.dk/remote/%s.asmx?op=%s", $type, $function), Am_HttpRequest::METHOD_POST);
$client->setHeader('Content-type', 'text/xml');
$client->setHeader('SOAPAction', sprintf("https://ssl.ditonlinebetalingssystem.dk/remote/%s/%s", $type, $function));
$client->setBody($xml = $this->createXML($type, $function, $vars));
$response = $client->send();
} catch (Exception $e) {
$this->getDi()->errorLogTable->logException($e);
throw new Am_Exception_InputError("Unable to contact webservice. Got error: " . $e->getMessage());
}
if (!$response->getBody()) {
throw new Am_Exception_InputError("Empty response received from API");
}
return $response->getBody();
}
示例8: __request
/**
*
* @param type $uri
* @param type $method
* @param type $headers
* @return HTTP_Request2_Response
*/
protected function __request($uri, $method = Am_HttpRequest::METHOD_GET, $headers = array())
{
$req = new Am_HttpRequest($uri, $method);
$req->setHeader('X-Auth-Token', $this->getAuthToken());
if (!empty($headers)) {
foreach ($headers as $k => $v) {
$req->setHeader($k, $v);
}
}
$response = $req->send();
return $response;
}
示例9: _sendMail
/**
* Send an email using the amazon webservice api
*
* @return void
*/
public function _sendMail()
{
$date = gmdate('D, d M Y H:i:s O');
//Send the request
$client = new Am_HttpRequest($this->_host, Am_HttpRequest::METHOD_POST);
$client->setHeader(array('Date' => $date, 'X-Amzn-Authorization' => $this->_buildAuthKey($date)));
//Build the parameters
$params = array('Action' => 'SendRawEmail', 'Source' => $this->_mail->getFrom(), 'RawMessage.Data' => base64_encode(sprintf("%s\n%s\n", $this->header, $this->body)));
$recipients = explode(',', $this->recipients);
while (list($index, $recipient) = each($recipients)) {
$params[sprintf('Destination.ToAddresses.member.%d', $index + 1)] = $recipient;
}
$client->addPostParameter($params);
$response = $client->send();
if ($response->getStatus() != 200) {
throw new Zend_Mail_Transport_Exception("Amazon SES: unexpected response: " . $response->getBody());
}
}
示例10: checkApiKeys
function checkApiKeys($vals)
{
$c = new Am_HttpRequest('https://sandbox.clickbank.com/rest/1.2/sandbox/product/list');
$c->setHeader('Accept', 'application/xml')->setHeader('Authorization', $vals['dev_key'] . ':' . $vals['clerk_key']);
$res = $c->send();
}
示例11: _sendMail
protected function _sendMail()
{
$request = new Am_HttpRequest(self::API_ENDPOINT . $this->_client_id, Am_HttpRequest::METHOD_POST);
$request->setAuth($this->_api_key, 'none');
$request->setHeader('Content-type: application/json; charset=utf-8');
$params = array('TrackOpens' => true, 'TrackClicks' => true, 'InlineCSS' => true);
$part = new Zend_Mail_Part(array('raw' => $this->header . Zend_Mime::LINEEND . $this->body));
$this->_extractHeaderToParams($part, 'to', $params);
$this->_extractHeaderToParams($part, 'cc', $params);
$this->_extractHeaderToParams($part, 'bcc', $params);
$this->_extractHeaderToParams($part, 'from', $params, false);
$this->_extractHeaderToParams($part, 'reply-to', $params, false);
$subject = $part->getHeader('subject');
if (strpos($subject, '=?') === 0) {
$subject = mb_decode_mimeheader($subject);
}
$params['subject'] = $subject;
$params['Group'] = $subject;
$canHasAttacments = false;
//message
list($type) = explode(";", $part->getHeader('content-type'));
if ($type == 'multipart/alternative') {
$msgPart = $part->getPart(2);
} else {
$msgPart = $part->isMultipart() ? $part->getPart(1) : $part;
if ($msgPart->isMultipart()) {
$msgPart = $msgPart->getPart(2);
//html part
}
$canHasAttacments = true;
}
list($type) = explode(";", $msgPart->getHeader('content-type'));
$encoding = $msgPart->getHeader('content-transfer-encoding');
$content = $msgPart->getContent();
if ($encoding && $encoding == 'quoted-printable') {
$content = quoted_printable_decode($content);
} else {
$content = base64_decode($content);
}
switch ($type) {
case 'text/plain':
$params['text'] = $content;
break;
case 'text/html':
$params['html'] = $content;
break;
default:
throw new Zend_Mail_Transport_Exception("SendGrid API: unknown content-type: " . $type);
}
//attachments
$handlers = array();
if ($canHasAttacments) {
if ($part->isMultipart()) {
$params['Attachments'] = array();
for ($i = 2; $i <= $part->countParts(); $i++) {
$attPart = $part->getPart($i);
$encoding = $attPart->getHeader('content-transfer-encoding');
$disposition = $attPart->getHeader('content-disposition');
preg_match('/filename="(.*)"/', $disposition, $m);
$filename = $m[1];
$content = $attPart->getContent();
if ($encoding && $encoding == 'quoted-printable') {
$content = quoted_printable_decode($content);
$content = base64_encode($content);
}
$params['Attachments'][] = array('Name' => $filename, 'Type' => $attPart->{'content-type'}, 'Content' => $content);
}
}
}
$request->setBody(json_encode($params));
$response = $request->send();
if (!($body = json_decode($response->getBody(), true)) || !isset($body[0]['Status']) || $body[0]['Status'] != 'Accepted') {
throw new Zend_Mail_Transport_Exception("CampaignMonitor API: unexpected response: " . $response->getBody());
}
}