本文整理汇总了PHP中Am_HttpRequest::setMethod方法的典型用法代码示例。如果您正苦于以下问题:PHP Am_HttpRequest::setMethod方法的具体用法?PHP Am_HttpRequest::setMethod怎么用?PHP Am_HttpRequest::setMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Am_HttpRequest
的用法示例。
在下文中一共展示了Am_HttpRequest::setMethod方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateLicense
/**
* Fetch updated license from aMember Pro website
*/
function updateLicense()
{
if (!$this->di->config->get('license')) {
return;
}
// empty license. trial?
if ($this->di->store->get('app-update-license-checked')) {
return;
}
try {
$req = new Am_HttpRequest('http://update.amember.com/license.php');
$req->setConfig('connect_timeout', 2);
$req->setMethod(Am_HttpRequest::METHOD_POST);
$req->addPostParameter('license', $this->di->config->get('license'));
$req->addPostParameter('root_url', $this->di->config->get('root_url'));
$req->addPostParameter('root_surl', $this->di->config->get('root_surl'));
$req->addPostParameter('version', AM_VERSION);
$this->di->store->set('app-update-license-checked', 1, '+12 hours');
$response = $req->send();
if ($response->getStatus() == '200') {
$newLicense = $response->getBody();
if ($newLicense) {
if (preg_match('/^L[A-Za-z0-9\\/=+\\n]+X$/', $newLicense)) {
Am_Config::saveValue('license', $newLicense);
} else {
throw new Exception("Wrong License Key Received: [" . $newLicense . "]");
}
}
}
} catch (Exception $e) {
if (APPLICATION_ENV != 'production') {
throw $e;
}
}
}
示例2: resendPostback
function resendPostback()
{
if ($this->plugin->getConfig('resend_postback')) {
$urls = $this->plugin->getConfig('resend_postback_urls');
$urls = explode("\n", $urls);
$urls = array_filter(array_map('trim', $urls));
foreach ($urls as $url) {
try {
$tm = microtime(true);
$this->log->add("Resending postback to [{$url}]");
if ($url == $this->plugin->getPluginUrl('ipn')) {
throw new Am_Exception_Configuration("DO NOT CONFIGURE RESENDING IPN TO ITSELF!");
}
$req = new Am_HttpRequest($url);
$req->setConfig('connect_timeout', 1000);
$req->setConfig('timeout', 2000);
$method = strtoupper($this->request->getMethod());
$req->setMethod($method);
if ($method == 'POST') {
foreach ($this->request->getPost() as $k => $v) {
$req->addPostParameter($k, $v);
}
} else {
$arr = $this->request->getQuery();
$req->setUrl($req->getUrl() . '?' . http_build_query($arr));
}
$req->send();
$tm = sprintf('%.3f', microtime(true) - $tm);
$this->log->add("Postback resent succesfully ({$tm} sec)");
} catch (Exception $e) {
$tm = sprintf('%.3f', microtime(true) - $tm);
$this->log->add("Cannot resend postback ({$tm} sec)");
$this->log->add($e);
}
}
}
}
示例3: _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;
}
示例4: _sendRequest
/** @return HTTP_Request2_Response */
public function _sendRequest(Am_HttpRequest $request)
{
$request->addPostParameter('x_login', $this->getConfig('login'));
$request->addPostParameter('x_tran_key', $this->getConfig('tkey'));
$request->addPostParameter('x_Delim_Data', "True");
$request->addPostParameter('x_Delim_Char', "|");
$request->addPostParameter('x_Version', "3.1");
$request->addPostParameter('x_method', "ECHECK");
if ($this->getConfig('test_mode')) {
$request->addPostParameter("x_test_request", "TRUE");
$request->setUrl(self::SANDBOX_URL);
} else {
$request->setUrl(self::LIVE_URL);
}
$request->setMethod(Am_HttpRequest::METHOD_POST);
return $request;
}