本文整理汇总了PHP中Am_HttpRequest::setConfig方法的典型用法代码示例。如果您正苦于以下问题:PHP Am_HttpRequest::setConfig方法的具体用法?PHP Am_HttpRequest::setConfig怎么用?PHP Am_HttpRequest::setConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Am_HttpRequest
的用法示例。
在下文中一共展示了Am_HttpRequest::setConfig方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadUpgradesList
function loadUpgradesList($requireAuth = false)
{
$req = new Am_HttpRequest('http://www.amember.com/check-upgrades.php', Am_HttpRequest::METHOD_POST);
$req->setConfig('connect_timeout', 5);
if (@$_REQUEST['beta'] > 0 || defined('AM_BETA') && AM_BETA) {
$req->addPostParameter('beta', 1);
}
$req->setConfig('timeout', 15);
$req->addPostParameter('am-version', AM_VERSION);
foreach ($this->getDi()->plugins as $type => $pm) {
foreach ($pm->getEnabled() as $v) {
$req->addPostParameter('plugins[' . $type . '][' . $v . ']', $pm->loadGet($v)->getVersion());
}
}
foreach ($this->getDi()->config->get('lang.enabled', array()) as $l) {
$req->addPostParameter('lang[]', $l);
}
$req->addPostParameter('php-version', PHP_VERSION);
$req->addPostParameter('mysql-version', $this->getDi()->db->selectCell("SELECT VERSION()"));
$req->addPostParameter('root-url', ROOT_URL);
$req->addPostParameter('root-surl', ROOT_SURL);
$req->addPostParameter('license', $this->getConfig('license'));
$token = $this->getDi()->store->get('amember-site-auth-token');
if (!$requireAuth) {
$token = 'TRIAL';
} elseif (!$token) {
$this->_redirect('admin-upgrade/get-token');
}
$req->addPostParameter('token', $token);
//
try {
$response = $req->send();
if ($response->getStatus() == 401) {
$this->_redirect('admin-upgrade/get-token');
}
} catch (HTTP_Request2_Exception $e) {
$this->view->title = ___('Update Error');
$this->view->content = ___('Could not fetch upgrades list from remote server. %sTry again%', '<a href="admin-upgrade">', '</a>');
$this->view->display('admin/layout.phtml');
return false;
}
if ($response->getStatus() != '200') {
throw new Am_Exception_InternalError(___("Could not fetch upgrades list. Connection error [%s]", $response->getReasonPhrase()));
}
$xml = new SimpleXMLElement($response->getBody());
$ret = array();
foreach ($xml->item as $u) {
$el = new stdclass();
foreach ($u->attributes() as $k => $v) {
$el->{$k} = (string) $v;
}
$el->text = (string) $u;
$el->text = strip_tags($el->text, '<li><ul><b><i><p><hr><br>');
$ret[] = $el;
}
return $ret;
}
示例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: 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;
}
}
}
示例4: dirname
<?php
require_once dirname(__FILE__) . '/bootstrap.php';
@set_time_limit(3600);
$req = new Am_HttpRequest();
$req->setConfig('connect_timeout', 120);
$req->setConfig('timeout', 3600);
$req->setUrl(Am_Di::getInstance()->config->get('root_url') . '/cron');
$resp = $req->send();