本文整理汇总了PHP中HttpClient::getSiteContent方法的典型用法代码示例。如果您正苦于以下问题:PHP HttpClient::getSiteContent方法的具体用法?PHP HttpClient::getSiteContent怎么用?PHP HttpClient::getSiteContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpClient
的用法示例。
在下文中一共展示了HttpClient::getSiteContent方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSearcherValue
function getSearcherValue($url, $searcher = "google")
{
$url = urlencode(preg_replace("#^http://#", "", $url));
$searcherUrls = array('google' => 'http://www.google.com/search?hl=en&q=site%3A' . $url, 'googlebl' => 'http://www.google.com/search?hl=en&q=link%3A' . $url);
$searcherPats = array('google' => "#</b> of (?:about )?<b>([\\d,]+)</b>#", 'googlebl' => "#</b> of (?:about )?<b>([\\d,]+)</b>#");
if (!array_key_exists($searcher, $searcherUrls)) {
$searcher = "google";
}
$sourceUrl = $searcherUrls[$searcher];
$httpClient = new HttpClient();
if ($this->extractionWay == 2) {
$httpClient->additionalServerUrl = $this->additionalServerUrl;
}
$buff = $httpClient->getSiteContent($sourceUrl);
if ($this->debug) {
echo $buff;
}
if (!preg_match($searcherPats[$searcher], $buff, $m)) {
$count = 0;
} else {
$count = str_replace(",", "", $m[1]);
$count = intval($count);
}
return $count;
}
示例2: logInAction
/**
* Display login form and login admin
*/
function logInAction()
{
if (isset($this->request->login) && isset($this->request->password)) {
if ($this->session->loginUser($this->request->login, md5($this->request->password), "login", "administrator")) {
$httpClient = new HttpClient();
$this->session->set("scriptLastVersion", $httpClient->getSiteContent("http://script.arfooo.com/version/version.html", false));
$this->redirect($this->moduleLink("index"));
} else {
$this->set("loginError", 1);
}
}
}
示例3: verifyCode
public function verifyCode($code)
{
$url = "http://www.allopass.com/check/vf.php4?";
$url .= "AUTH=" . urlencode($this->product->allopassId);
$url .= "&CODE=";
for ($i = 0, $n = count($code); $i < $n; $i++) {
$url .= urlencode($code[$i]);
if ($i + 1 < $n) {
$url .= ",";
}
}
$url .= "&MAXT=" . $this->allopassMaxTime;
$httpClient = new HttpClient();
$buff = $httpClient->getSiteContent($url, false);
return strncmp("OK", $buff, 2) == 0;
}
示例4: checkScriptVersion
function checkScriptVersion()
{
require CODE_ROOT_DIR . "config/version.php";
$lastVersion = $this->session->get("scriptLastVersion");
if (!$lastVersion) {
$httpClient = new HttpClient();
$lastVersion = $httpClient->getSiteContent("http://script.arfooo.com/version/version.html", false);
if (!$lastVersion) {
$lastVersion = "-";
}
$this->session->set("scriptLastVersion", $lastVersion);
}
$newVersionAvailable = version_compare($lastVersion, $currentVersion, ">");
$this->set("currentVersion", $currentVersion);
$this->set("lastVersion", $lastVersion);
$this->set("newVersionAvailable", $newVersionAvailable);
}
示例5: getPageRank
function getPageRank($url, $additionalServerUrl = false)
{
$pageRank = 0;
$url = substr(strtolower($url), 0, 7) != "http://" ? "http://" . $url : $url;
$queryUrl = "http://" . $this->googleDomains[mt_rand(0, count($this->googleDomains) - 1)];
$queryUrl .= sprintf("/tbr?client=navclient-auto&ch=6%s&features=Rank&q=info:%s", $this->googleCh($this->strord("info:" . $url)), urlencode($url));
$httpClient = new HttpClient();
if ($additionalServerUrl) {
$httpClient->additionalServerUrl = $additionalServerUrl;
}
$content = $httpClient->getSiteContent($queryUrl, false);
if ($this->debug) {
echo $content;
}
if (preg_match("#Rank_1:\\d:(\\d{1,2})#", $content, $matches)) {
$pageRank = $matches[1];
}
return $pageRank;
}
示例6: addAddress
public function addAddress($address, $description = '')
{
$url = self::GEO_URL . '?&output=json&q=' . urlencode($address);
if (@ini_get('allow_url_fopen')) {
$buff = @file_get_contents($url);
} else {
$httpClient = new HttpClient();
$buff = $httpClient->getSiteContent($url, false);
}
$response = json_decode(utf8_encode($buff), true);
if (empty($response['Status']['code'])) {
throw new Google_Map_ServiceException('Invalid status code');
}
if (empty($response['Placemark'][0]['Point']['coordinates'])) {
throw new Google_Map_AddressNotFoundException('Point can NOT be found');
}
$coords = $response['Placemark'][0]['Point']['coordinates'];
$point = array('lat' => $coords[1], 'lng' => $coords[0], 'address' => $address, 'description' => $description);
array_push($this->_points, $point);
return array('lat' => $coords[1], 'lng' => $coords[0]);
}
示例7: downloadAndCacheThumb
function downloadAndCacheThumb($forced = false)
{
$imageFileName = Config::get("SITES_THUMBS_PATH") . $this->siteId . ".jpg";
if (!file_exists($imageFileName) || $forced) {
if (!Config::get("thumbsGeneratorUrl")) {
throw new Exception("thumbsGeneratorUrl not set");
}
$url = $this->getThumbGeneratorSiteUrl();
$httpClient = new HttpClient();
$thumbImage = $httpClient->getSiteContent($url, false, true, true);
if ($thumbImage) {
// check whether the image is valid
if (function_exists('imagecreatefromstring') && @imagecreatefromstring($thumbImage) === false) {
throw new Exception("Downloaded thumb is not an image");
}
file_put_contents($imageFileName, $thumbImage);
}
}
}
示例8: handleIpn
public function handleIpn()
{
$ipnData = $this->request;
$postData = 'cmd=_notify-validate';
foreach ($ipnData as $key => $value) {
$postData .= "&" . urlencode($key) . "=" . urlencode($value);
}
$httpClient = new HttpClient();
$url = $this->getActionUrl();
$buff = $httpClient->getSiteContent($url, false, true, false, "POST", $postData);
if (strcmp($buff, "VERIFIED") != 0) {
return $this->payLog("Request isn't VERIFIED", "error");
}
if ($this->debug) {
$this->payLog(var_export($ipnData, true) . "\r\n");
}
if ($this->debug) {
$this->payLog($postData . "\r\n");
}
foreach (array("item_number", "receiver_email", "mc_gross", "mc_currency", "txn_type", "payment_status") as $key) {
if (empty($ipnData[$key])) {
return $this->payLog("Field {$key} is not set", "error");
}
}
$this->currentPayment = $this->payment->findByPk($ipnData['item_number']);
$errorMessage = $this->validatePayment($ipnData);
if ($errorMessage) {
return $this->payLog($errorMessage, "error");
}
switch ($ipnData['txn_type']) {
case "web_accept":
switch ($ipnData['payment_status']) {
case "Completed":
$this->onComplete();
break;
case "Pending":
$this->onPending();
break;
case "Denied":
$this->onDenied();
break;
}
break;
default:
return $this->payLog("Unhandled txn_type", "error");
}
return $this->payLog("Finished");
}