本文整理汇总了PHP中Piwik::sendHttpRequest方法的典型用法代码示例。如果您正苦于以下问题:PHP Piwik::sendHttpRequest方法的具体用法?PHP Piwik::sendHttpRequest怎么用?PHP Piwik::sendHttpRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik
的用法示例。
在下文中一共展示了Piwik::sendHttpRequest方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: check
/**
* Check for a newer version
*/
public static function check()
{
$lastTimeChecked = Piwik_GetOption(self::LAST_TIME_CHECKED);
if($lastTimeChecked === false
|| time() - self::CHECK_INTERVAL > $lastTimeChecked )
{
$parameters = array(
'piwik_version' => Piwik_Version::VERSION,
'php_version' => phpversion(),
'url' => Piwik_Url::getCurrentUrlWithoutQueryString(),
'trigger' => Piwik_Common::getRequestVar('module','','string'),
);
$url = self::PIWIK_HOST . "?" . http_build_query($parameters, '', '&');
$timeout = self::SOCKET_TIMEOUT;
try {
$latestVersion = Piwik::sendHttpRequest($url, $timeout);
Piwik_SetOption(self::LATEST_VERSION, $latestVersion);
} catch(Exception $e) {
// e.g., disable_functions = fsockopen; allow_url_open = Off
Piwik_SetOption(self::LATEST_VERSION, '');
}
Piwik_SetOption(self::LAST_TIME_CHECKED, time(), $autoload = 1);
}
}
示例2: _retrieveCurrentValue
function _retrieveCurrentValue()
{
$this->current_value = PHP_VERSION;
$url = 'http://php.net/releases/?serialize=1&version=5';
$timeout = Piwik_UpdateCheck::SOCKET_TIMEOUT;
try {
$latestVersion = Piwik::sendHttpRequest($url, $timeout);
$versionInfo = Piwik_Common::unserialize_array($latestVersion);
$this->recommended_value = $versionInfo['version'];
} catch (Exception $e) {
$this->recommended_value = '';
}
}
示例3: getFeedData
/**
* Returns array of counts and images based on Feedburner URI
*
* @param string $uri
* @return array()
*/
protected function getFeedData($uri)
{
// Awareness API only supports yesterday and back
// we get stats for previous two days
// http://code.google.com/apis/feedburner/awareness_api.html#dates
$yesterday = date('Y-m-d', mktime(0, 0, 0, date("m"), date("d") - 1, date("Y")));
$beforeYesterday = date('Y-m-d', mktime(0, 0, 0, date("m"), date("d") - 2, date("Y")));
//create url to gather XML feed from
$url = 'http://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=' . $uri . '&dates=' . $beforeYesterday . ',' . $yesterday . '';
$data = Piwik::sendHttpRequest($url, 5);
try {
$xml = new SimpleXMLElement($data);
} catch (Exception $e) {
return "Error parsing the data for feed {$uri}. Fetched data was: \n'" . $data . "'";
}
if (count($xml->feed->entry) != 2) {
return "Error fetching the Feedburner stats. Expected XML, Got: \n" . strip_tags($data);
}
$data = array();
$i = 0;
foreach ($xml->feed->entry as $feedDay) {
$data[0][$i] = $feedDay['circulation'];
$data[1][$i] = $feedDay['hits'];
$data[2][$i] = $feedDay['reach'];
$i++;
}
foreach ($data as $key => $value) {
if ($value[0] == $value[1]) {
$img = 'nochange.gif';
} else {
if ($value[0] < $value[1]) {
$img = 'arrow-up-green.gif';
} else {
$img = 'arrow-down-red.gif';
}
}
$prefixImage = '<img alt="" src="./plugins/ExampleFeedburner/templates/';
$suffixImage = '" />';
$data[$key][2] = $prefixImage . $img . $suffixImage;
}
return $data;
}
示例4: generalSetup
function generalSetup()
{
$this->checkPreviousStepIsValid( __FUNCTION__ );
$view = new Piwik_Installation_View(
$this->pathView . 'generalSetup.tpl',
$this->getInstallationSteps(),
__FUNCTION__
);
$this->skipThisStep( __FUNCTION__ );
$form = new Piwik_Installation_FormGeneralSetup();
if($form->validate())
{
$superUserInfos = array(
'login' => $form->getSubmitValue('login'),
'password' => md5( $form->getSubmitValue('password') ),
'email' => $form->getSubmitValue('email'),
'salt' => Piwik_Common::generateUniqId(),
);
$this->session->superuser_infos = $superUserInfos;
$host = 'http://api.piwik.org/1.0/';
$host .= 'subscribeNewsletter/';
$params = array(
'email' => $form->getSubmitValue('email'),
'security' => $form->getSubmitValue('subscribe_newsletter_security'),
'community' => $form->getSubmitValue('subscribe_newsletter_community'),
'url' => Piwik_Url::getCurrentUrlWithoutQueryString(),
);
if($params['security'] == '1'
|| $params['community'] == '1')
{
if( !isset($params['security'])) { $params['security'] = '0'; }
if( !isset($params['community'])) { $params['community'] = '0'; }
$url = $host . '?' . http_build_query($params, '', '&');
try {
Piwik::sendHttpRequest($url, $timeout = 2);
} catch(Exception $e) {
// e.g., disable_functions = fsockopen; allow_url_open = Off
}
}
$this->redirectToNextStep( __FUNCTION__ );
}
$view->addForm($form);
echo $view->render();
}
示例5: generalSetup
function generalSetup()
{
$this->checkPreviousStepIsValid(__FUNCTION__);
$view = new Piwik_Installation_View($this->pathView . 'generalSetup.tpl', $this->getInstallationSteps(), __FUNCTION__);
$this->skipThisStep(__FUNCTION__);
$session = new Zend_Session_Namespace("Installation");
require_once "FormGeneralSetup.php";
$form = new Piwik_Installation_FormGeneralSetup();
if ($form->validate()) {
$superUserInfos = array('login' => $form->getSubmitValue('login'), 'password' => md5($form->getSubmitValue('password')), 'email' => $form->getSubmitValue('email'));
$session->superuser_infos = $superUserInfos;
$host = 'http://api.piwik.org/1.0/';
$host .= 'subscribeNewsletter/';
$params = array('email' => $form->getSubmitValue('email'), 'security' => $form->getSubmitValue('subscribe_newsletter_security'), 'community' => $form->getSubmitValue('subscribe_newsletter_community'), 'url' => Piwik_Url::getCurrentUrlWithoutQueryString());
if ($params['security'] == '1' || $params['community'] == '1') {
if (!isset($params['security'])) {
$params['security'] = '0';
}
if (!isset($params['community'])) {
$params['community'] = '0';
}
$url = $host . "?" . http_build_query($params, '', '&');
Piwik::sendHttpRequest($url, $timeout = 2);
}
$this->redirectToNextStep(__FUNCTION__);
}
$view->addForm($form);
echo $view->render();
}