当前位置: 首页>>代码示例>>PHP>>正文


PHP Am_HttpRequest::setBody方法代码示例

本文整理汇总了PHP中Am_HttpRequest::setBody方法的典型用法代码示例。如果您正苦于以下问题:PHP Am_HttpRequest::setBody方法的具体用法?PHP Am_HttpRequest::setBody怎么用?PHP Am_HttpRequest::setBody使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Am_HttpRequest的用法示例。


在下文中一共展示了Am_HttpRequest::setBody方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _process

 public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
 {
     $req = new Am_HttpRequest(sprintf('https://gateway-japa.americanexpress.com/api/rest/version/23/merchant/%s/session', $this->getConfig('merchant')), Am_HttpRequest::METHOD_POST);
     $req->setAuth('merchant.' . $this->getConfig('merchant'), $this->getConfig('password'));
     $req->setBody(Am_Controller::getJson(array('apiOperation' => 'CREATE_PAYMENT_PAGE_SESSION', 'order' => array('id' => $invoice->public_id, 'amount' => $invoice->first_total, 'currency' => $invoice->currency), 'paymentPage' => array('cancelUrl' => $this->getCancelUrl(), 'returnUrl' => $this->getPluginUrl('thanks')))));
     $this->logRequest($req);
     $res = $req->send();
     $this->logResponse($res);
     if ($res->getStatus() != 201) {
         $result->setFailed(sprintf('Incorrect Responce Status From Paysystem [%s]', $res->getStatus()));
         return;
     }
     $msg = Am_Controller::decodeJson($res->getBody());
     if ($msg['result'] == 'ERROR') {
         $result->setFailed($msg['error']['explanation']);
         return;
     }
     $invoice->data()->set(self::DATA_KEY, $msg['successIndicator'])->update();
     $a = new Am_Paysystem_Action_Redirect(self::URL);
     $a->{'merchant'} = $this->getConfig('merchant');
     $a->{'order.description'} = $invoice->getLineDescription();
     $a->{'paymentPage.merchant.name'} = $this->getDi()->config->get('site_title');
     $a->{'session.id'} = $msg['session']['id'];
     $this->logRequest($a);
     $result->setAction($a);
 }
开发者ID:grlf,项目名称:eyedock,代码行数:26,代码来源:amex-hpp.php

示例2: _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);
 }
开发者ID:grlf,项目名称:eyedock,代码行数:27,代码来源:eway.php

示例3: 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;
 }
开发者ID:grlf,项目名称:eyedock,代码行数:20,代码来源:wepay.php

示例4: apiRequest

 function apiRequest($table, $value)
 {
     $url = self::APIURL . $this->getPlugin()->getConfig('merchant_id') . "/" . $table . "/" . $value;
     try {
         $r = new Am_HttpRequest($url, Am_HttpRequest::METHOD_POST);
         $r->setBody("<Request><Key>" . $this->getPlugin()->getConfig('key') . "</Key></Request>");
         $resp = $r->send()->getBody();
         $xml = simplexml_load_string($resp);
         if (!$xml) {
             throw new Am_Exception_Paysystem_TransactionInvalid('1SC API response is not a valid XML:' . $resp);
         }
         if ((string) $xml->attributes()->success != 'true') {
             throw new Am_Exception_Paysystem_TransactionInvalid('1SC API response is not sucessfull: ' . $resp);
         }
     } catch (Exception $e) {
         Am_Di::getInstance()->errorLogTable->logException($e);
         return null;
     }
     return $xml;
 }
开发者ID:alexanderTsig,项目名称:arabic,代码行数:20,代码来源:1shoppingcart.php

示例5: 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();
 }
开发者ID:irovast,项目名称:eyedock,代码行数:17,代码来源:epay.php

示例6: _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());
     }
 }
开发者ID:grlf,项目名称:eyedock,代码行数:75,代码来源:Mail.php


注:本文中的Am_HttpRequest::setBody方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。