本文整理汇总了PHP中HTTPRequest::DownloadToString方法的典型用法代码示例。如果您正苦于以下问题:PHP HTTPRequest::DownloadToString方法的具体用法?PHP HTTPRequest::DownloadToString怎么用?PHP HTTPRequest::DownloadToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTTPRequest
的用法示例。
在下文中一共展示了HTTPRequest::DownloadToString方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: DownloadToString
function DownloadToString()
{
$crlf = "\r\n";
// generate request
$req = 'GET ' . $this->_uri . ' HTTP/1.0' . $crlf . 'Host: ' . $this->_host . $crlf . $crlf;
// fetch
$this->_fp = fsockopen(($this->_protocol == 'https' ? 'ssl://' : '') . $this->_host, $this->_port);
fwrite($this->_fp, $req);
while (is_resource($this->_fp) && $this->_fp && !feof($this->_fp)) {
$response .= fread($this->_fp, 1024);
}
fclose($this->_fp);
// split header and body
$pos = strpos($response, $crlf . $crlf);
if ($pos === false) {
return $response;
}
$header = substr($response, 0, $pos);
$body = substr($response, $pos + 2 * strlen($crlf));
// parse headers
$headers = array();
$lines = explode($crlf, $header);
foreach ($lines as $line) {
if (($pos = strpos($line, ':')) !== false) {
$headers[strtolower(trim(substr($line, 0, $pos)))] = trim(substr($line, $pos + 1));
}
}
// redirection?
if (isset($headers['location'])) {
$http = new HTTPRequest($headers['location']);
return $http->DownloadToString($http);
} else {
return $body;
}
}
示例2: WPMediaFeed_content_filter
function WPMediaFeed_content_filter($content)
{
$url = "";
$delimiter = "";
$start = 0;
$mode = "";
$dest_url = "";
//Some validation and filtering
if (strpos($content, "[WPMediaFeed-Youtube]") !== false) {
$content = str_replace("[WPMediaFeed-Youtube]", "", $content);
$url = get_option('WPMediaFeed-Youtube-Channel');
$delimiter = "watch?v=";
$start = 1;
//For YT, skip the first record. It's garbage.
$dest_url = "http://www.youtube.com/watch?v=";
$mode = "youtube";
} else {
if (strpos($content, "[WPMediaFeed-Soundcloud]") !== false) {
$content = str_replace("[WPMediaFeed-Soundcloud]", "", $content);
$url = get_option('WPMediaFeed-Soundcloud-Channel');
$delimiter = '<a class="sound__coverArt" href="';
$dest_url = "https://w.soundcloud.com/player/?url=" . $url;
$mode = "soundcloud";
} else {
//Only get the feed if the shortcode is present.
return $content;
}
}
if (!$url || $url == "") {
return $content;
}
//Download the channel HTML
require_once dirname(__FILE__) . '/HTTPRequest.class.php';
$req = new HTTPRequest($url);
$html = $req->DownloadToString();
//Next, parse it to get the media IDs
$mediaParts = explode($delimiter, $html);
$mediaIds = array();
//skip the first one - it's bogus
for ($i = $start; $i < sizeof($mediaParts); $i++) {
$part = $mediaParts[$i];
$mediaId = strstr($part, "\"", true);
//echo "VideoId: $videoId , length: " . strlen($videoId) . "<br>";
//Youtube videoIds should always be 11 chars long, but let's keep it open for future compatibility
if ($mode == "youtube" && strlen($mediaId) > 10 || $mode == "soundcloud") {
if (!in_array($mediaId, $mediaIds)) {
array_push($mediaIds, $mediaId);
}
}
}
//Finally, output the embed links to the unique videos
foreach ($mediaIds as $mediaId) {
$content .= '[embed]' . $dest_url . $mediaId . '[/embed]';
}
return $content;
}
示例3: httpClientCall
function httpClientCall($allUrl, $charset)
{
$this->_url = $allUrl;
$this->_scan_url();
$crlf = "\r\n";
$response = "";
// generate request
$req = 'GET ' . $this->_uri . ' HTTP/1.0' . $crlf . 'Host: ' . $this->_host . $crlf . $crlf;
// fetch
try {
$this->_fp = fsockopen(($this->_protocol == 'https' ? 'ssl://' : '') . $this->_host, $this->_port);
fwrite($this->_fp, $req);
while (is_resource($this->_fp) && $this->_fp && !feof($this->_fp)) {
$response .= fread($this->_fp, 1024);
}
} catch (Exception $e) {
fclose($this->_fp);
throw new SDKRuntimeException("http请求失败:" + $e . getMessage());
} catch (SDKRuntimeException $e) {
die($e->errorMessage());
}
// split header and body
$pos = strpos($response, $crlf . $crlf);
if ($pos === false) {
return $response;
}
$header = substr($response, 0, $pos);
$body = substr($response, $pos + 2 * strlen($crlf));
// parse headers
$headers = array();
$lines = explode($crlf, $header);
foreach ($lines as $line) {
if (($pos = strpos($line, ':')) !== false) {
$headers[strtolower(trim(substr($line, 0, $pos)))] = trim(substr($line, $pos + 1));
}
}
// redirection?
if (isset($headers['location'])) {
$http = new HTTPRequest($headers['location']);
return $http->DownloadToString($http);
} else {
return $body;
}
}
示例4: copyWUfile
function copyWUfile()
{
global $WUsourceFile, $context, $WUcacheFile, $fopenOff;
if ($fopenOff) {
include './fopener.php';
$read = new HTTPRequest($WUsourceFile);
$wsource = $read->DownloadToString();
} else {
$wsource = file_get_contents($WUsourceFile, 0, $context);
}
$ctarget = fopen($WUcacheFile, "w");
fwrite($ctarget, $wsource);
fclose($ctarget);
return true;
}
示例5: rss_import_showpage
//.........这里部分代码省略.........
$QEIPA = array('table_name' => table_prefix . 'feeds', 'field_name' => 'feed_submitter', 'key' => 'feed_id', 'field_type' => 'number');
// the type of database field we are reading from / writing to
$smarty->assign('qeip_FeedSubmitter', $QEIPA);
$QEIPA = array('table_name' => table_prefix . 'feed_link', 'field_name' => 'feed_field', 'key' => 'feed_link_id', 'eip_type' => 'select');
// the type of EIP field to show
$smarty->assign('qeip_FeedLink_FeedField', $QEIPA);
$QEIPA = array('table_name' => table_prefix . 'feed_link', 'field_name' => 'pligg_field', 'key' => 'feed_link_id', 'eip_type' => 'select');
// the type of EIP field to show
$smarty->assign('qeip_FeedLink_PliggField', $QEIPA);
// feed oldest first
$QEIPA = array('table_name' => table_prefix . 'feeds', 'field_name' => 'feed_last_item_first', 'key' => 'feed_id');
// a unique identifier for the row
$smarty->assign('qeip_FeedLastItemFirst', $QEIPA);
// feed random vote
$QEIPA = array('table_name' => table_prefix . 'feeds', 'field_name' => 'feed_random_vote_enable', 'key' => 'feed_id');
// a unique identifier for the row
$smarty->assign('qeip_FeedRandomVoteEnable', $QEIPA);
// feed random vote min
$QEIPA = array('table_name' => table_prefix . 'feeds', 'field_name' => 'feed_random_vote_min', 'key' => 'feed_id', 'field_type' => 'number');
// the type of database field we are reading from / writing to
$smarty->assign('qeip_FeedRandomVotesMin', $QEIPA);
// feed random vote max
$QEIPA = array('table_name' => table_prefix . 'feeds', 'field_name' => 'feed_random_vote_max', 'key' => 'feed_id', 'field_type' => 'number');
// the type of database field we are reading from / writing to
$smarty->assign('qeip_FeedRandomVotesMax', $QEIPA);
$QEIP = new QuickEIP();
if (!isset($_REQUEST['action'])) {
$smarty->assign('tpl_center', rss_import_tpl_path . 'admin_rss_center');
$main_smarty->display($template_dir . '/admin/admin.tpl');
echo $QEIP->ShowOnloadJS();
} else {
if ($_REQUEST['action'] == "addnewfieldlink") {
$RSSImport = new RSSImport();
$RSSImport->FeedLinkId = $_REQUEST['FeedLinkId'];
$RSSImport->new_field_link();
redirect('module.php?module=rss_import&action=editfeed&feed_id=' . $_REQUEST['FeedLinkId']);
}
if ($_REQUEST['action'] == "dropfieldlink") {
$RSSImport = new RSSImport();
$RSSImport->FeedLinkId = $_REQUEST['FeedLinkId'];
$RSSImport->drop_field_link();
redirect('module.php?module=rss_import');
}
if ($_REQUEST['action'] == "addnewfeed") {
$RSSImport = new RSSImport();
$RSSImport->FeedName = "New Feed";
$RSSImport->new_feed();
redirect('module.php?module=rss_import');
}
if ($_REQUEST['action'] == "dropfeed") {
$RSSImport = new RSSImport();
$RSSImport->FeedId = $_REQUEST['feed_id'];
$RSSImport->drop_feed();
redirect('module.php?module=rss_import');
}
if ($_REQUEST['action'] == "save") {
echo $QEIP->save_field($smarty);
}
if ($_REQUEST['action'] == "examinefeed") {
$RSSImport = new RSSImport();
$RSSImport->FeedId = $_REQUEST['feed_id'];
$RSSImport->read_feed();
$rss = fetch_rss($RSSImport->FeedURL);
$z = $rss->items[0];
if ($z) {
echo 'First item in the feed.<hr />';
print_r_html($z);
echo '<hr />Feed dump.<hr />';
print_r_html($rss);
} else {
echo '<hr />There are no items in this feed<hr />';
}
}
if ($_REQUEST['action'] == "editfeed") {
$RSSImport = new RSSImport();
$RSSImport->FeedId = $_REQUEST['feed_id'];
$smarty->assign('tpl_center', rss_import_tpl_path . 'admin_rss_center2');
$main_smarty->display($template_dir . '/admin/admin.tpl');
}
if ($_REQUEST['action'] == "exportfeed") {
echo 'copy all the text in the box<br />';
echo '<textarea rows=10 cols=70>' . serialize_feed($_REQUEST['feed_id']) . '</textarea>';
echo '<br /><br /><a href = "module.php?module=rss_import">return to the rss importer</a>';
}
if ($_REQUEST['action'] == "importprebuiltfeed_go") {
$feed = stripslashes($_REQUEST['prebuiltfeed']);
if (strpos($feed, '://') < 10) {
$r = new HTTPRequest($feed);
$feed = $r->DownloadToString();
}
if (import_prebuilt($feed)) {
redirect(my_pligg_base . '/module.php?module=rss_import');
} else {
// what do we do if error?
}
}
}
//echo $QEIP->ShowOnloadJS();
}
}
示例6: TelegramAPI
<?php
ini_set('error_reporting', E_ALL);
require 'TelegramAPI.php';
require 'HTTPRequest.php';
$tg = new TelegramAPI();
$chat_id = null;
$guessed = false;
$sendQuestion = false;
$data = $tg->getWebhookUpdates();
$chat_id = $data['message']['chat']['id'];
$text = $data['message']['text'];
$tg->sendChatAction($chat_id, "natijani kuting...");
$urlmehnat = 'http://mehnat.uz/mehnatbot/mehnatbot.php';
$r = new HTTPRequest($urlmehnat);
$result = (array) json_decode($r->DownloadToString());
/*$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_URL, $urlmehnat);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = (array)json_decode(curl_exec($ch));
curl_close($ch);
*/
//$result = (array)json_decode('{"zarplata":"131300","razryad":[{"id":"9","razryad":"1","koef":"2.476"},{"id":"10","razryad":"2","koef":"2.725"},{"id":"11","razryad":"3","koef":"2.998"},{"id":"12","razryad":"4","koef":"3.297"},{"id":"13","razryad":"5","koef":"3.612"},{"id":"14","razryad":"6","koef":"3.941"},{"id":"15","razryad":"7","koef":"4.284"},{"id":"16","razryad":"8","koef":"4.64"},{"id":"17","razryad":"9","koef":"4.997"},{"id":"18","razryad":"10","koef":"5.362"},{"id":"19","razryad":"11","koef":"5.733"},{"id":"20","razryad":"12","koef":"6.115"},{"id":"21","razryad":"13","koef":"6.503"},{"id":"22","razryad":"14","koef":"6.893"},{"id":"23","razryad":"15","koef":"7.292"},{"id":"24","razryad":"16","koef":"7.697"},{"id":"25","razryad":"17","koef":"8.106"},{"id":"26","razryad":"18","koef":"8.522"},{"id":"27","razryad":"19","koef":"8.943"},{"id":"28","razryad":"20","koef":"9.371"},{"id":"29","razryad":"21","koef":"9.804"},{"id":"30","razryad":"22","koef":"10.24"}]}');
print_r($result);
if (strcmp($text, "/minimalka") === 0) {
$natija = "Hozirgi kunda eng kam oylik ish haqi - " . $result['zarplata'] . " so'm";
} elseif ($tg->startsWith($text, "/maosh")) {
$string = "Maosh hisoblash uchun quyidagi ko'rinishda kiriting (1-21): \nMasalan: \n /maosh 7";
if ($text == "/maosh") {
$natija = $string;
示例7: template_management_download
function template_management_download($download_path)
{
global $main_smarty;
// Method for identifying modules
define('modulename', 'template_management');
$main_smarty->assign('modulename', modulename);
$main_smarty->display(template_management_tpl_path . '/blank.tpl');
$x = explode('/', str_replace('.tar', '', $download_path));
$filename = '/' . $x[count($x) - 2] . '_template.tar';
$r = new HTTPRequest($download_path);
$somecontent = $r->DownloadToString();
$filename = './templates' . $filename;
if (!($handle = fopen($filename, 'w'))) {
return "Cannot open file ({$filename})";
}
if (fwrite($handle, $somecontent) === FALSE) {
return "Cannot write to file ({$filename})";
}
fclose($handle);
return $main_smarty->get_config_vars('PLIGG_Template_Management_DownloadSuccess');
}
示例8: validDomain
function validDomain($domain)
{
if (!empty($domain)) {
App::import('Vendor', 'httprequest');
$r = new HTTPRequest('http://www.' . $domain);
$content = $r->DownloadToString();
if (!empty($content)) {
return true;
} else {
return false;
}
} else {
return false;
}
}
示例9: exec
$zipline = "tar czf " . $dbname . "-" . $date . "_sql.tar.gz {$dbname}-{$date}.sql";
shell_exec($zipline);
}
if ($remove_sql_file == "yes") {
exec("rm -r -f {$filename}");
}
if ($use_gzip == "yes") {
$filename2 = "{$savepath}/" . $dbname . "-" . $date . "_sql.tar.gz";
} else {
$filename2 = "{$savepath}/{$dbname}-{$date}.sql";
}
# add echo the results of applying the backup script before sending the backup by email
$url = DATABASE_RESTORE_SCRIPT_URL . "?filename={$filename}";
echo "The disaster recovery script is at " . $url . "\n";
# execute the restore script on the disaster recovery site
echo $s->DownloadToString();
# send an email with a copy of the backup
if ($send_email == "yes") {
$fileatt_type = filetype($filename2);
if ($use_gzip == "yes") {
$fileatt_name = "" . $dbname . "-" . $date . "_sql.tar.gz";
} else {
$fileatt_name = "" . $dbname . "-" . $date . ".sql";
}
$headers = "From: {$from}";
// Read the file to be attached ('rb' = read binary)
$file = fopen($filename2, 'rb');
$data = fread($file, filesize($filename2));
fclose($file);
// Generate a boundary string
$semi_rand = md5(time());
示例10: exit
// create and parse or skip if cache file exists
if (time() - @filemtime($dirCont . '/' . $WUID . '-day-' . $cYear . $cMnth . zero_bd($cDay - 1) . '.txt') < $pause and $cron and !isset($tloop) and $cDay - 1 != 0) {
exit("Error: This page can be reloaded only once every " . $pause / 60 . ".minutes.");
}
$tloop = false;
$unitsLnk = $metric ? 'metric' : 'english';
$WUsourceFile2 = 'http://www.wunderground.com/weatherstation/WXDailyHistory.asp?ID=' . $WUID . '&graphspan=day&day=' . zero_bd($cDay) . '&year=' . $cYear . '&month=' . $cMnth . '&format=1&units=' . $unitsLnk;
$WUcacheFile2 = $dirCont . '/' . $WUID . '-day-' . $cYear . $cMnth . zero_bd($cDay) . '.txt';
## cache file creation
$opts = array('http' => array('method' => 'GET', 'header' => 'Cookie: Units=' . $unitsLnk));
$context = stream_context_create($opts);
// context HEADER with cookie for changing units
if ($fopenOff) {
include './fopener.php';
$read = new HTTPRequest($WUsourceFile2);
$wsource2 = $read->DownloadToString();
} else {
$wsource2 = file_get_contents($WUsourceFile2, 0, $context);
}
$ctarget2 = fopen($WUcacheFile2, "w");
fwrite($ctarget2, $wsource2);
fclose($ctarget2);
parse_wu_day($WUcacheFile2, $cYear, $cMnth, zero_bd($cDay), true);
// for calculation a creation Average baro, solar and wind cache files
$cpEnd = $cron ? true : false;
// at once in WU pages and more steps in cron mode given by $cronFiles in WU-precache.php
$sbl++;
//echo '<br>copied<br>';
continue;
} else {
$fileExists++;
示例11: HTTPRequest
<?php
include_once "class.httprequest.php";
#Send Audit Trail mail everyday
$r = new HTTPRequest("http://www.acravonline.com/index.php/settings/cronmail/send_cron_mail/type/help");
echo $r->DownloadToString();
示例12: urlencode
if ($SendName) {
@file_get_contents($remVerCheck . '?name=' . urlencode(utf8_encode($stationName)) . '&i=1&web=' . urlencode($_SERVER['HTTP_HOST']));
}
}
@fclose($vf);
}
} else {
// create verify file, version will be checked in next page load.
$vf = @fopen($verFile, "w");
if ($fopenOff) {
include './fopener.php';
$read1 = new HTTPRequest($remVerCheck);
@fwrite($vf, trim($read1->DownloadToString()));
if ($SendName) {
$read2 = new HTTPRequest($remVerCheck . '?name=' . urlencode(utf8_encode($stationName)) . '&i=1&web=' . urlencode($_SERVER['HTTP_HOST']));
$wugarb = $read2->DownloadToString();
}
} else {
@fwrite($vf, trim(@file_get_contents($remVerCheck)));
if ($SendName) {
@file_get_contents($remVerCheck . '?name=' . urlencode(utf8_encode($stationName)) . '&i=1&web=' . urlencode($_SERVER['HTTP_HOST']));
}
}
@fclose($vf);
}
// Check version for information at the bottom of the page.
if (version_compare(VERSION, trim(@file_get_contents($verFile)), '<')) {
$nwVerAvail = true;
} else {
$nwVerAvail = false;
}
示例13: gravatar_get_url
function gravatar_get_url($url, $timeout = 10)
{
global $gravatar_options;
switch ($gravatar_options['gravatar_rcache_method']) {
case "curl":
$curl_handle = curl_init();
curl_setopt($curl_handle, CURLOPT_URL, $url);
curl_setopt($curl_handle, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, $timeout);
$data = curl_exec($curl_handle);
// curl_close($curl_handle);
// REST API SUCKAGE:
$httpcode = curl_getinfo($curl_handle, CURLINFO_HTTP_CODE);
curl_close($curl_handle);
if ($httpcode >= 300 && $httpcode <= 400) {
return "redirected";
}
return $data;
case "fsockopen":
default:
$hr = new HTTPRequest($url, $timeout);
return $hr->DownloadToString();
}
}
示例14: populate_db
function populate_db()
{
global $ft, $_WEB_URL;
# put in links
$ft->dbh->_do_query('INSERT INTO tbl:sitelinks (linkid, name, url, sort) VALUES (NULL, ?, ?, ?)', array('Home', "{$_WEB_URL}/", 50));
# now fetch what we need for 'regions'
$fetch = array('regions' => array('regionid', 'name'), 'constellations' => array('constellationid', 'name'), 'systems' => array('systemid', 'regionid', 'constellationid', 'name', 'security'), 'itemtypes' => array('typeid', 'groupid', 'name', 'baseprice', 'icon'), 'itemgroups' => array('groupid', 'categoryid', 'name'));
# now get the data
foreach ($fetch as $tbl => $cols) {
$r = new HTTPRequest("http://www.eve-dev.com/setup_dumper.php?table={$tbl}");
$str = $r->DownloadToString();
$rows = explode("\n", $str);
$colstr = implode(',', $cols);
# now break it on newlines
foreach ($rows as $row) {
$row = trim($row);
if ($row[0] == "#") {
continue;
}
# make some SQL
$ft->dbh->_do_query("INSERT INTO tbl:{$tbl} ({$colstr}) VALUES ({$row})");
}
}
}