本文整理汇总了PHP中Am_HttpRequest::send方法的典型用法代码示例。如果您正苦于以下问题:PHP Am_HttpRequest::send方法的具体用法?PHP Am_HttpRequest::send怎么用?PHP Am_HttpRequest::send使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Am_HttpRequest
的用法示例。
在下文中一共展示了Am_HttpRequest::send方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run(Am_Paysystem_Result $result)
{
$this->result = $result;
$log = $this->getInvoiceLog();
$log->add($this->request);
$this->response = $this->request->send();
$log->add($this->response);
$this->validateResponseStatus($this->result);
if ($this->result->isFailure()) {
return;
}
try {
$this->parseResponse();
// validate function must set success status
$this->validate();
if ($this->result->isSuccess()) {
$this->processValidated();
}
} catch (Exception $e) {
if ($e instanceof PHPUnit_Framework_Error) {
throw $e;
}
if ($e instanceof PHPUnit_Framework_Asser) {
throw $e;
}
if (!$result->isFailure()) {
$result->setFailed(___("Payment failed"));
}
$log->add($e);
}
}
示例2: sendRequest
public function sendRequest($method, $params = array())
{
$this->vars = $params;
$this->vars['api_key'] = $this->plugin->getConfig('api_key');
$this->vars['api_user'] = $this->plugin->getConfig('api_user');
$this->setUrl(self::API_URL . '/' . $method . '.json');
foreach ($this->vars as $k => $v) {
$this->addPostParameter($k, $v);
}
$ret = parent::send();
if ($ret->getStatus() != '200') {
throw new Am_Exception_InternalError("SendGrid API Error:" . $ret->getBody());
}
$body = $ret->getBody();
if (!$body) {
return array();
}
$arr = json_decode($body, true);
if (!$arr) {
throw new Am_Exception_InternalError("SendGrid API Error - unknown response [" . $ret->getBody() . "]");
}
if (@$arr['message'] == 'error') {
Am_Di::getInstance()->errorLogTable->log("Sendgrid API Error - [" . implode(', ', $arr['errors']) . "]");
return false;
}
return $arr;
}
示例3: validateSource
public function validateSource()
{
$request = new Am_HttpRequest($this->getPlugin()->getConfig('testing') ? Am_Paysystem_Cashenvoy::SANDBOX_STATUS_URL : Am_Paysystem_Cashenvoy::LIVE_STATUS_URL, Am_HttpRequest::METHOD_POST);
$request->addPostParameter(array('mertid' => $this->getPlugin()->getConfig('merchant_id'), 'transref' => $this->request->getFiltered("ce_transref"), 'respformat' => 'json'));
$response = $request->send();
$this->vars = json_decode($response->getBody(), true);
$this->log->add($this->vars);
return true;
}
示例4: sendRequest
function sendRequest($data, $method)
{
$request = new Am_HttpRequest('http://api.moon-ray.com/cdata.php', Am_HttpRequest::METHOD_POST);
$request->addPostParameter(array('appid' => $this->getConfig('app_id'), 'key' => $this->getConfig('app_key'), 'return_id' => 1, 'reqType' => $method, 'data' => $data));
$ret = $request->send();
if ($ret->getStatus() != '200') {
throw new Am_Exception_InternalError("Officeautopilot API Error");
}
$res = $ret->getBody();
if (preg_match("|<error>(.*)</error>|", $res, $r)) {
throw new Am_Exception_InternalError("Officeautopilot API Error - unknown response [" . $r[1] . "]");
}
return $res;
}
示例5: call
public function call($method, $params = null)
{
$this->setBody(json_encode($this->prepCall($method, $params)));
$this->setHeader('Expect', '');
$ret = parent::send();
if ($ret->getStatus() != '200') {
throw new Am_Exception_InternalError("GetResponse API Error, is configured API Key is wrong");
}
$arr = json_decode($ret->getBody(), true);
if (!$arr) {
throw new Am_Exception_InternalError("GetResponse API Error - unknown response [" . $ret->getBody() . "]");
}
if (isset($arr['error'])) {
throw new Am_Exception_InternalError("GetResponse API Error - {$arr['error']['code']} : {$arr['error']['message']}");
}
return $arr['result'];
}
示例6: loadPaymentData
/**
*
* @param type $xmlURL
* @return Am_Fortumo_Service_Details $details;
* @throws Am_Exception_InternalError
*/
public function loadPaymentData($xmlURL)
{
$req = new Am_HttpRequest($xmlURL, Am_HttpRequest::METHOD_GET);
$resp = $req->send();
$body = $resp->getBody();
if (empty($body)) {
throw new Am_Exception_InternalError('Fortumo plugin: Empty response from service XML url');
}
$xml = simplexml_load_string($body);
if ($xml === false) {
throw new Am_Exception_InternalError("Fortumo plugin: Can't parse incoming xml");
}
if ((int) $xml->status->code !== 0) {
throw new Am_Exception_InternalError("Fortumo plugin: Request status is not OK GOT: " . (int) $xml->status->code);
}
return Am_Fortumo_Service_Details::create($xml);
}
示例7: validateSource
public function validateSource()
{
$vars = $this->request->getPost();
$vars['tipo'] = 'CP';
$vars['Comando'] = 'validar';
$vars['Token'] = $this->getPlugin()->getConfig('token');
$vars['email_cobranca'] = $this->getPlugin()->getConfig('merchant');
try {
$r = new Am_HttpRequest("https://pagseguro.uol.com.br/Security/NPI/Default.aspx?" . http_build_query($vars, '', '&'));
$response = $r->send();
} catch (Exception $e) {
$this->getPlugin()->getDi()->errorLogTable->logException($e);
}
if ($response && $response->getBody() == 'VERIFICADO') {
return true;
}
throw new Am_Exception_Paysystem_TransactionSource('Incorrect transaction received. Please contact webmaster for details');
}
示例8: changeSubscription
public function changeSubscription(\User $user, array $addLists, array $deleteLists)
{
if (!empty($addLists)) {
$req = new Am_HttpRequest($this->getConfig('install_url') . '/subscriber/optIn.php', Am_HttpRequest::METHOD_POST);
foreach (array('api_action' => 'add', 'api_key' => $this->getConfig('api_key'), 'api_send_email' => $this->getConfig('api_send_email') ? 'yes' : 'no', 'email' => $user->email, 'double_optin' => $this->getConfig('double_optin', 0), 'lists' => implode(',', $addLists)) as $k => $v) {
$req->addPostParameter($k, $v);
}
$req->send();
}
if (!empty($deleteLists)) {
$req = new Am_HttpRequest($this->getConfig('install_url') . '/subscriber/optOut.php', Am_HttpRequest::METHOD_POST);
foreach (array('api_action' => 'remove', 'api_key' => $this->getConfig('api_key'), 'api_send_email' => $this->getConfig('api_send_email') ? 'yes' : 'no', 'email' => $user->email, 'opt_out_type' => 1, 'lists' => implode(',', $addLists)) as $k => $v) {
$req->addPostParameter($k, $v);
}
$req->send();
}
return true;
}
示例9: _getCountry
public function _getCountry($ip)
{
$req = new Am_HttpRequest(sprintf(self::URL, $ip), Am_HttpRequest::METHOD_GET);
$req->setAuth($this->getAccountId(), $this->getAccountLicense());
try {
$response = $req->send();
} catch (Exception $e) {
throw new Am_Exception_InternalError("MaxMind GeoLocation service: Unable to contact server (got: " . $e->getMessage() . " )");
}
$resp = json_decode($response->getBody());
if ($response->getStatus() !== 200) {
throw new Am_Exception_InternalError("MaxMind GeoLocation service: Got an error from API server (got: " . $resp->error . " )");
}
if (!empty($resp->error)) {
return null;
}
return (string) $resp->country->iso_code;
}
示例10: apiRequest
public function apiRequest($method, $vars)
{
$req = new Am_HttpRequest(self::API_URL . "/" . $method . ".html", Am_HttpRequest::METHOD_POST);
$req->addPostParameter('merchantid', $this->getConfig('merchant_id'));
$req->addPostParameter('signature', $this->getConfig('api_signature'));
foreach ($vars as $k => $v) {
$req->addPostParameter($k, $v);
}
$req->send();
$resp = $req->getBody();
if (!$resp) {
throw new Am_Exception_InputError('PWC: got empty response from API server');
}
$xml = simplexml_load_string($resp);
if ($xml->error) {
throw new Am_Exception_InputError('PWC: Got error from API: ' . $xml->error->errortext);
}
return $xml;
}
示例11: _process
public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
{
$req = new Am_HttpRequest(self::LIVE_URL, Am_HttpRequest::METHOD_POST);
$req->addPostParameter(array('method' => 'create', 'address' => $this->getConfig('address'), 'callback' => $this->getPluginUrl('ipn') . "?secret=" . $invoice->getSecureId('THANKS') . '&invoice_id=' . $invoice->public_id));
$res = $req->send();
$arr = (array) json_decode($res->getBody(), true);
if (empty($arr['input_address'])) {
throw new Am_Exception_InternalError($res->getBody());
}
$req = new Am_HttpRequest(self::CURRENCY_URL . "?currency={$invoice->currency}&value={$invoice->first_total}", Am_HttpRequest::METHOD_GET);
$res = $req->send();
$amount = $res->getBody();
if (doubleval($amount) <= 0) {
throw new Am_Exception_InternalError($amount);
}
$invoice->data()->set(self::BLOCKHAIN_AMOUNT, doubleval($amount))->update();
$a = new Am_Paysystem_Action_HtmlTemplate_Blockchain($this->getDir(), 'confirm.phtml');
$a->amount = doubleval($amount);
$a->input_address = $arr['input_address'];
$a->invoice = $invoice;
$result->setAction($a);
}
示例12: array
function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
{
$user = $invoice->getUser();
$data = array('VERSION' => "0001", 'STAMP' => $invoice->public_id . '-' . $this->getDi()->time, 'AMOUNT' => $invoice->first_total * 100, 'REFERENCE' => $invoice->public_id, 'MESSAGE' => $invoice->getLineDescription(), 'LANGUAGE' => "FI", 'MERCHANT' => $this->getConfig('merchant_id'), 'RETURN' => $this->getPluginUrl('thanks'), 'CANCEL' => $this->getCancelUrl(), 'REJECT' => "", 'DELAYED' => "", 'COUNTRY' => "FIN", 'CURRENCY' => "EUR", 'DEVICE' => "10", 'CONTENT' => "1", 'TYPE' => "0", 'ALGORITHM' => "1", 'DELIVERY_DATE' => date("Ymd"), 'FIRSTNAME' => $user->name_f, 'FAMILYNAME' => $user->name_l, 'ADDRESS' => $user->street . ($user->street2 ? '; ' . $user->street2 : ''), 'POSTCODE' => $user->zip, 'POSTOFFICE' => "");
$data['MAC'] = $this->getMac(self::$coMapOut, $data);
$req = new Am_HttpRequest(self::URL, Am_HttpRequest::METHOD_POST);
$req->addPostParameter($data);
$this->logRequest($data);
$res = $req->send();
if ($res->getStatus() != '200') {
throw new Am_Exception_InternalError(self::LOG_PREFIX_ERROR . "[_process()] - bad status of server response [{$res->getStatus()}]");
}
if (!($body = $res->getBody())) {
throw new Am_Exception_InternalError(self::LOG_PREFIX_ERROR . "[_process()] - server return null");
}
$this->logResponse($body);
if (!($xml = simplexml_load_string($body))) {
throw new Am_Exception_InternalError(self::LOG_PREFIX_ERROR . "[_process()] - server return bad xml");
}
$a = new Am_Paysystem_Action_HtmlTemplate_Checkout($this->getDir(), 'payment-checkout-redirect.phtml');
$a->xml = $xml;
$result->setAction($a);
}
示例13: _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);
}
}
示例14: upgradeFlowPlayerKey
function upgradeFlowPlayerKey()
{
if (version_compare($this->db_version, '4.2.16') < 0) {
echo "Update Flowplayer License Key...";
if (ob_get_level()) {
ob_end_flush();
}
$request = new Am_HttpRequest('https://www.amember.com/fplicense.php', Am_HttpRequest::METHOD_POST);
$request->addPostParameter('root_url', $this->getDi()->config->get('root_url'));
try {
$response = $request->send();
} catch (Exception $e) {
echo "request failed " . $e->getMessage() . "\n<br />";
return;
}
if ($response->getStatus() == 200) {
$body = $response->getBody();
$res = Am_Controller::decodeJson($body);
if ($res['status'] == 'OK' && $res['license']) {
Am_Config::saveValue('flowplayer_license', $res['license']);
}
}
echo "Done<br>\n";
}
}
示例15: _process
public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
{
$encoded = file_get_contents(dirname(__FILE__) . '/resource.cgn');
$decoded = $this->zapakiraj($this->simpleXOR($this->odpakiraj($encoded)));
$temp = tempnam(DATA_DIR, 'bnk');
file_put_contents($temp, $decoded);
$zipFile = zip_open($temp);
while ($zipEntry = zip_read($zipFile)) {
if (zip_entry_name($zipEntry) == $this->getConfig('terminal_id') . '.xml') {
$zip_entry_exist = true;
if (zip_entry_open($zipFile, $zipEntry)) {
$readStream = zip_entry_read($zipEntry);
$data = unpack("N*", $readStream);
for ($i = 1; $i < count($data) + 1; $i++) {
$data1[$i - 1] = $data[$i];
}
$xorData = $this->simpleXOR($data1);
$bin = null;
for ($i = 0; $i < count($xorData); $i++) {
$bin .= pack("N", $xorData[$i]);
}
$decoded = unpack("C*", $bin);
$xmlString = "";
for ($i = 1; $i < count($decoded) + 1; $i++) {
$xmlString .= chr($decoded[$i]);
}
$strData = $xmlString;
zip_entry_close($zipEntry);
}
}
}
zip_close($zipFile);
if (!$zip_entry_exist) {
$this->getDi()->errorLogTable->log("BANKART API ERROR : terminal xml file is not found in cgn file");
throw new Am_Exception_InputError(___('Error happened during payment process. '));
}
//for some reasone xml is broken in bankart cgn file
$strData = preg_replace("/\\<\\/term[a-z]+\$/", '</terminal>', $strData);
$terminal = new SimpleXMLElement($strData);
$port = (string) $terminal->port[0];
$context = (string) $terminal->context[0];
if ($port == "443") {
$url = "https://";
} else {
$url = "http://";
}
$url .= (string) $terminal->webaddress[0];
if (strlen($port) > 0) {
$url .= ":" . $port;
}
if (strlen($context) > 0) {
if ($context[0] != "/") {
$url .= "/";
}
$url .= $context;
if (!$context[strlen($context) - 1] != "/") {
$url .= "/";
}
} else {
$url .= "/";
}
$url .= "servlet/PaymentInitHTTPServlet";
$vars = array('id' => (string) $terminal->id[0], 'password' => (string) $terminal->password[0], 'passwordhash' => (string) $terminal->passwordhash[0], 'action' => 4, 'amt' => $invoice->first_total, 'currency' => $this->currency_codes[$invoice->currency], 'responseURL' => $this->getPluginUrl('ipn'), 'errorURL' => $this->getRootUrl() . "/cancel", 'trackId' => $invoice->public_id, 'udf1' => $invoice->public_id);
$req = new Am_HttpRequest($url, Am_HttpRequest::METHOD_POST);
$req->addPostParameter($vars);
$res = $req->send();
$body = $res->getBody();
if (strpos($body, 'ERROR') > 0) {
$this->getDi()->errorLogTable->log("BANKART API ERROR : {$body}");
throw new Am_Exception_InputError(___('Error happened during payment process. '));
}
list($payment_id, $url) = explode(':', $body, 2);
$invoice->data()->set('bankart_payment_id', $payment_id)->update();
$a = new Am_Paysystem_Action_Redirect($url . '?PaymentID=' . $payment_id);
$result->setAction($a);
}