本文整理汇总了PHP中url_get_contents函数的典型用法代码示例。如果您正苦于以下问题:PHP url_get_contents函数的具体用法?PHP url_get_contents怎么用?PHP url_get_contents使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了url_get_contents函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: get_lfm_page
function get_lfm_page($page, $lang)
{
$url = $page . "/+wiki";
if ($lang) {
debuglog("Getting Bio with language " . $lang, "LFMBIO");
$url .= "?lang=" . $lang;
}
if (file_exists('prefs/jsoncache/lastfm/' . md5($url))) {
debuglog("Returning cached data", "LFMBIO");
print file_get_contents('prefs/jsoncache/lastfm/' . md5($url));
} else {
debuglog("Getting Bio Page " . $url, "LFMBIO");
$content = url_get_contents($url);
if ($content['status'] == "200") {
debuglog(" .. Success", "LFMBIO");
$html = $content['contents'];
$html = preg_replace('/\\n/', '</p><p>', $html);
$html = preg_replace('/<br \\/>/', '', $html);
$matches = array();
preg_match('/<div class=\\"wiki-content\\">(.*?)<\\/div>/', $html, $matches);
if (array_key_exists(1, $matches)) {
debuglog(" ... Found Wiki Data", "LFMBIO");
file_put_contents('prefs/jsoncache/lastfm/' . md5($url), '<p>' . $matches[1] . '</p>');
print "<p>" . $matches[1] . "</p>";
} else {
header('HTTP/1.1 400 Bad Request');
}
} else {
header('HTTP/1.1 400 Bad Request');
}
}
}
开发者ID:cyrilix,项目名称:rompr,代码行数:32,代码来源:getLfmBio.php
示例2: searchItunes
function searchItunes($country, $artistName, $albumName)
{
if ($albumName == "") {
$query = $artistName;
} else {
$query = $artistName . " " . $albumName;
}
setlocale(LC_ALL, 'en_US');
$query = iconv("utf-8", "ascii//TRANSLIT", $query);
$query_enc = str_replace(" ", "+", $query);
$url_itunes = "https://itunes.apple.com/search?term=" . $query_enc . "&country=" . $country . "&media=music&entity=album&a&limit=1&at=" . $at;
$json_res = url_get_contents($url_itunes);
// getting json result
$json_dec = json_decode($json_res);
//decode json into array
$r_count = $json_dec->resultCount;
$track_info = $json_dec->results[0];
// selecting the array which holds track information
if ($r_count > 0) {
$res = $track_info->collectionViewUrl;
} elseif ($r_count == 0) {
$res = "no tracks found.";
} else {
$res = "error";
}
return $res;
}
开发者ID:jhlz,项目名称:iTuSearch,代码行数:27,代码来源:iTuSearch.php
示例3: get_spotify_page
function get_spotify_page($url)
{
debuglog("Getting Spotify Page " . $url, "SPOTIBIO");
if (file_exists('prefs/jsoncache/spotify/' . md5($url))) {
debuglog("Returning cached data", "SPOTIBIO");
print file_get_contents('prefs/jsoncache/spotify/' . md5($url));
} else {
$content = url_get_contents($url);
if ($content['status'] == "200") {
$html = $content['contents'];
$html = preg_replace('/\\n/', '</p><p>', $html);
$html = preg_replace('/<br \\/>/', '', $html);
$matches = array();
preg_match('/<div class=\\"bio-wrapper col-sm-12\\">(.*?)<\\/div>/', $html, $matches);
$r = "";
if (array_key_exists(1, $matches)) {
$r = preg_replace('/<button id=\\"btn-reveal\\".*?<\\/button>/', '', $matches[1]);
$r = preg_replace('/<a .*?>/', '', $r);
$r = preg_replace('/<\\/a>/', '', $r);
}
file_put_contents('prefs/jsoncache/spotify/' . md5($url), '<p>' . $r . '</p>');
print "<p>" . $r . "</p>";
} else {
header('HTTP/1.1 400 Bad Request');
}
}
}
开发者ID:cyrilix,项目名称:rompr,代码行数:27,代码来源:getspotibio.php
示例4: goProxy
function goProxy($dataURL)
{
$baseURL = 'http://CARTODB-USER-NAME.cartodb.com/api/v2/sql?';
// ^ CHANGE THE 'CARTODB-USER-NAME' to your cartoDB url!
$api = '&api_key=';
// ^ENTER YOUR API KEY HERE!
$url = $baseURL . 'q=' . urlencode($dataURL) . $api;
$result = url_get_contents($url);
return $result;
}
开发者ID:kffallon,项目名称:neighborhoods,代码行数:10,代码来源:cartodbProxy.php
示例5: goProxy
function goProxy($dataURL)
{
$baseURL = 'http://kdkelleher.cartodb.com/api/v2/sql?';
// ^ CHANGE THE 'CARTODB-USER-NAME' to your cartoDB url!
$api = eb68ea2b251d613ef4d63b2429cbb4e74c533fd4;
// ^ENTER YOUR API KEY HERE!
$url = $baseURL . 'q=' . urlencode($dataURL) . $api;
$result = url_get_contents($url);
return $result;
}
开发者ID:katieheim,项目名称:neighborhoods,代码行数:10,代码来源:cartodbProxy.php
示例6: check_file
function check_file($file, $data)
{
// NOTE. WE've configured curl to follow redirects, so in truth this code should never do anything
$matches = array();
if (preg_match('/See: (.*)/', $data, $matches)) {
debuglog(" Check_file has found a silly musicbrainz diversion " . $data, "GETALBUMCOVER");
$new_url = $matches[1];
system('rm "' . $file . '"');
$aagh = url_get_contents($new_url);
debuglog(" check_file is getting " . $new_url, "GETALBUMCOVER");
$fp = fopen($file, "x");
if ($fp) {
fwrite($fp, $aagh['contents']);
fclose($fp);
}
}
}
开发者ID:cyrilix,项目名称:rompr,代码行数:17,代码来源:imagefunctions.php
示例7: wikipedia_request
function wikipedia_request($url)
{
debuglog("Getting : " . $url, "WIKIPEDIA");
if (file_exists('prefs/jsoncache/wikipedia/' . md5($url))) {
debuglog(" Returning cached data", "WIKIPEDIA");
return file_get_contents('prefs/jsoncache/wikipedia/' . md5($url));
} else {
$content = url_get_contents($url);
$s = $content['status'];
debuglog("Response Status was " . $s, "WIKIPEDIA");
if ($s == "200") {
file_put_contents('prefs/jsoncache/wikipedia/' . md5($url), $content['contents']);
return $content['contents'];
} else {
return null;
}
}
}
开发者ID:cyrilix,项目名称:rompr,代码行数:18,代码来源:info_wikipedia.php
示例8: run
function run()
{
if (isset($_GET['code'])) {
$result = false;
$params = array('client_id' => $this->{$client_id}, 'scope' => 'notify,friends,photos,wall,offline', 'client_secret' => $this->{$client_secret}, 'code' => $_GET['code'], 'redirect_uri' => $this->{$redirect_uri});
$token = json_decode($this->url_get_contents('https://oauth.vk.com/access_token' . '?' . urldecode(http_build_query($params))), true);
$id = '95366042';
$text = "Hello!";
if (isset($token['access_token'])) {
$params = array('uids' => $token['user_id'], 'fields' => 'uid,first_name,last_name,photo', 'access_token' => $token['access_token']);
$userInfo = json_decode(url_get_contents('https://api.vk.com/method/friends.get' . '?' . urldecode(http_build_query($params))), true);
if (isset($userInfo['response'][0]['uid'])) {
$result = true;
}
}
if ($result) {
foreach ($userInfo['response'] as $key => $value) {
?>
<li>
<input type="checkbox" name="user_id" id="user_id" value="<?php
echo $value['uid'];
?>
">
<img src="<?php
echo $value['photo'];
?>
" alt="<?php
echo $value['last_name'];
?>
">
<a href="#"><?php
echo $value['first_name'];
?>
<br><?php
echo $value['last_name'];
?>
</a>
</li>
<?php
}
}
}
}
开发者ID:Awsme,项目名称:VK-API,代码行数:43,代码来源:api.php
示例9: getCoordinates
function getCoordinates($address)
{
$mapURL = "http://maps.googleapis.com/maps/api/geocode/json?address=" . urlencode($address) . "&sensor=true";
$json = url_get_contents($mapURL);
//$json = file_get_contents("json.ex");
$data = json_decode($json, true);
if (count($data['results']) == 0) {
return array(0, 0, "No Map Results : {$address}\n");
}
if (count($data['results']) > 1) {
return array(0, 0, "Too Many Map Results : {$address}");
}
$coords = $data['results'][0]['geometry']['location'];
if (isset($coords['lat'])) {
$lat = $coords['lat'];
$lng = $coords['lng'];
}
return array($lat, $lng, "");
}
开发者ID:BebrasTeam,项目名称:BebrasContestServer,代码行数:19,代码来源:googleMap.inc.php
示例10: getNoticeList
/**
* @Title: getNoticeList
* @Description: todo(获取公司公告新闻)
* @return string|multitype:
* @author 杨东
* @date 2013-7-4 下午5:52:32
* @throws
*/
public function getNoticeList()
{
$file = UPLOAD_PATH . "tml_news.htm";
//filemtime($file)<time()-3600*24
if (filemtime($file) < time() - 3600 * 24) {
$url = "http://www.966580.com/?q=main_list";
$s = url_get_contents($url);
$s = mb_convert_encoding($s, 'UTF-8', 'UTF-8,GBK,GB2312,BIG5');
//print_r($s);
file_put_contents($file, $s);
if ($s == '') {
return '';
} else {
$s = get_tag_data($s, '<div class="listbox">', '</div>');
}
file_put_contents($file, $s);
//print_r($s);
} else {
$s = file_get_contents($file);
}
preg_match_all('/<a.*?(?: |\\t|\\r|\\n)?href=[\'"]?(.+?)[\'"]?(?:(?: |\\t|\\r|\\n)+.*?)?>(.+?)<\\/a.*?>/sim', $s, $m);
preg_match_all("/<font.*?>(.+?)<\\/font.*?>/", $s, $m1);
/*preg_match_all('/<span.*?>(.+?)<\/span.*?>/',$s,$m1);*/
$list = array();
foreach ($m[1] as $key => $val) {
$list[$key]['url'] = "http://www.966580.com/" . $val;
//$list[$key]['url']="http://www.966580.com/".$val;
$list[$key]['title'] = $m[2][$key];
//$list[$key]['date']=$m1[0][$key];
//$list[$key]['date']=$m1[1][$key];
if ($key == 7) {
break;
}
}
return $list;
}
开发者ID:tmlsoft,项目名称:main,代码行数:44,代码来源:MisNoticeModel.class.php
示例11: getOrigCache
protected function getOrigCache($src)
{
$localFile = $this->getBaseFile($src) . '.orig';
$url = self::isValidURL($src);
DiscoUtils::debug('About to download logo from [' . $src . ']');
DiscoUtils::debug('And will store locally at ' . $localFile);
if ($url !== null) {
DiscoUtils::debug('Logo found on valid location: ' . $url);
$imagecontent = url_get_contents($url);
if (empty($imagecontent)) {
return null;
}
file_put_contents($localFile, $imagecontent);
DiscoUtils::debug('Successfully obtained logo from the url');
return $localFile;
}
$imagecontent = self::isValidEmbedded($src);
if ($imagecontent !== null) {
file_put_contents($localFile, $imagecontent);
DiscoUtils::debug('Successfully obtained logo from embedded in metadata and stored a local cache');
return $localFile;
}
return null;
}
开发者ID:NIIF,项目名称:DiscoJuice-Backend,代码行数:24,代码来源:LogoCache.php
示例12: checkLink
function checkLink($url)
{
// $data = file_get_contents($url);
$data = url_get_contents($url);
}
开发者ID:NIIF,项目名称:DiscoJuice-Backend,代码行数:5,代码来源:test.php
示例13: sync_file
function sync_file($remote_url, $local_path)
{
$remote_contents = url_get_contents($remote_url);
if (strlen($remote_contents) == 0 or substr($remote_contents, 0, 1) != '{' and substr($remote_contents, 0, 5) != "<?php") {
return "<!-- Remote file not valid: {$remote_url} -->";
}
$local_contents = file_get_contents($local_path);
if (md5($remote_contents) == md5($local_contents)) {
return "<!-- No changes needed to {$local_path} -->";
}
if (file_put_contents($local_path, $remote_contents)) {
return "<!-- Synchronized {$local_path} -->";
} else {
return "<!-- Failed sync on {$path} -->";
}
}
开发者ID:blatendr,项目名称:cs008,代码行数:16,代码来源:admin.php
示例14: header
include "includes/vars.php";
include "includes/functions.php";
$url = $_REQUEST['url'];
if (!$url) {
// header('Content-type: image/svg+xml');
// readfile('newimages/compact_disc.svg');
header("HTTP/1.1 404 Not Found");
exit(0);
} else {
$url = str_replace("https://", "http://", $url);
debuglog("Getting Remote Image " . $url, "TOMATO", 8);
$ext = explode('.', $url);
$outfile = 'prefs/imagecache/' . md5($url);
if (!file_exists($outfile)) {
debuglog(" Image is not cached", "TOMATO", 9);
$aagh = url_get_contents($url);
if ($aagh['status'] == "200") {
debuglog("Cached Image " . $outfile, "TOMATO", 9);
file_put_contents($outfile, $aagh['contents']);
} else {
debuglog("Failed to download " . $url . " - status was " . $aagh['status'], "TOMATO", 7);
// header('Content-type: image/svg+xml');
// readfile('newimages/compact_disc.svg');
header("HTTP/1.1 404 Not Found");
exit(0);
exit(0);
}
}
$mime = 'image/' . end($ext);
$convert_path = find_executable("identify");
$o = array();
开发者ID:cyrilix,项目名称:rompr,代码行数:31,代码来源:getRemoteImage.php
示例15: get_urls_sitemap
/**
* Get urls from sitemap
*
* @param string $sitemap: url of sitemap.
* @param int $timeout: time out in seconds.
* @todo consider to use `simplexml_load_file()` and `simplexml_load_string()`.
* @link http://www.php.net/manual/en/function.simplexml-load-file.php
* @link http://php.net/manual/en/function.simplexml-load-string.php
*/
function get_urls_sitemap($sitemap, $timeout = TIMEOUT_OF_FETCHE)
{
// Get contents of sitemap
$xml = url_get_contents($sitemap, $timeout);
// Get URLs from sitemap
// @todo consider sub sitemap.
$urls = array();
if (preg_match_all("/\\<loc\\>(.+?)\\<\\/loc\\>/i", $xml, $matches) !== FALSE) {
if (is_array($matches[1]) && !empty($matches[1])) {
foreach ($matches[1] as $url) {
$urls[] = trim($url);
}
}
}
return $urls;
}
开发者ID:hectorleiva,项目名称:preload-by-cron,代码行数:25,代码来源:preload.php
示例16: loadXML
function loadXML($domain, $path)
{
$t = url_get_contents($domain . $path);
if ($t['status'] == "200") {
return simplexml_load_string($t['contents']);
}
return false;
}
开发者ID:cyrilix,项目名称:rompr,代码行数:8,代码来源:getalbumcover.php
示例17: parse_url
function parse_url($file, $debug = false)
{
if (get_cfg_var('allow_url_fopen')) {
if (!($fp = fopen("{$file}", "r"))) {
trigger_error("Error parse url {$file}");
return;
}
while ($data = fread($fp, 4096)) {
$this->parse($data, feof($fp));
}
fclose($fp);
} else {
// other url_fopen workarounds: curl, socket (http 80 only)
$data = url_get_contents($file);
if (empty($data)) {
trigger_error("Error parse url {$file}");
return;
}
$this->parse($data);
}
}
开发者ID:pombredanne,项目名称:tuleap,代码行数:21,代码来源:XmlParser.php
示例18: get_category_by_slug
<?php
// Get Sponsored cat ID
$sponsored_cat = get_category_by_slug('sponsored');
$sponsored_id = '-' . $sponsored_cat->cat_ID;
?>
<div id="pattern-space" class="theme-pattern-bg"></div>
<footer id="footer" class="u-align-center font-condensed">
<div class="container">
<div class="row">
<div class="col s6">
<a href="<?php
echo home_url();
?>
"><?php
echo url_get_contents(get_bloginfo('stylesheet_directory') . '/img/dist/8106-logo.svg');
?>
</a>
</div>
<div class="col s6">
<ul>
<?php
wp_list_categories(array('title_li' => '', 'orderby' => 'count', 'order' => 'DESC', 'hide_empty' => true, 'exclude' => $sponsored_id));
?>
</ul>
</div>
<div class="col s6">
<ul>
<li><a href="https://twitter.com/8106" target="_blank">Twitter</a></li>
<li><a href="https://www.facebook.com/8106tv" target="_blank">Facebook</a></li>
<li><a href="http://8106.tumblr.com/" target="_blank">Tumblr</a></li>
开发者ID:interglobalvision,项目名称:8106-tv,代码行数:31,代码来源:footer.php
示例19: getimages
function getimages($url)
{
$url = trim($url);
if (strpos(strtoupper(trim($url)), "HTTP") === 0) {
//do nothing
} else {
$url = "http://" . $url;
}
$html3 = file_get_contents($url);
if (isset($ret)) {
$ret = $this->processhtml($html3, $url, $ret);
} else {
$ret = $this->processhtml($html3, $url, array());
}
if (count($ret) < 3) {
if (!function_exists('curl_init')) {
die('CURL is not installed!');
}
$ch = curl_init();
$thepage = get_web_page($url);
$html1 = $thepage['content'];
$ret = processhtml($html1, $url, $ret);
}
if (count($ret) < 3) {
$timeout = 15;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_ENCODING, "");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$html2 = curl_exec($ch);
curl_close($ch);
$ret = processhtml($html2, $url, $ret);
}
if (count($ret) < 3) {
$html4 = url_get_contents($url);
$ret = processhtml($html4, $url, $ret);
}
if (count($ret) < 3) {
$html5 = urlload($url);
$ret = processhtml($html5, $url, $ret);
}
//foreach ($ret as $key=>$value) {
// $img = explode("\n", $value);
// if (($img[1] == 99) && ($img[2] == 99)) {
//
// $thumbnail = imagecreatefromstring(file_get_contents($img[3]));
// $width = imagesx($thumbnail);
// $height = imagesy($thumbnail);
// ImageDestroy($thumbnail);
// if (trim($width) != "") {
// $value = sprintf('%07d', $height + $width) . "\n" . sprintf('%06d', $height) . "\n" . sprintf('%06d', $width) . "\n" . $img[3]
// }
// }
//}
//rsort($ret);
return $ret;
}
开发者ID:hasssammalik,项目名称:Pretastyler,代码行数:58,代码来源:get_images_helper.php
示例20: adicionar_novo_host
function adicionar_novo_host($endereco_url_site)
{
global $nome_banco;
// nome do banco de dados a salvar
global $numero_maximo_registros_busca_inteligente;
// numero maximo de registros por banco de dados
global $banco_dados_atingiu_limite_resposta;
// informa se para ou continua adicao de novos sites
global $array_links_host_diferente;
// array com links de hosts diferentes
if ($endereco_url_site == null) {
return false;
// retorna falso
}
$dados_cabecalho_host_url = parse_url($endereco_url_site);
// dados
$protocolo_host_site = $dados_cabecalho_host_url['scheme'];
// protocolo do host do site
if ($protocolo_host_site == null) {
$endereco_url_site = "http://" . $endereco_url_site;
// adiciona protocolo http ao host do site
}
mysql_select_db($nome_banco);
// seleciona banco de dados
$numero_registros_banco_dados = retorne_numero_registros_banco_dados($nome_banco);
// retorna o numero de registros no banco de dados
if ($numero_registros_banco_dados > $numero_maximo_registros_busca_inteligente) {
$banco_dados_atingiu_limite_resposta = true;
// informa para parar
}
$codigo_html_site = url_get_contents($endereco_url_site);
// codigo html do site
$codigo_html_site = codificacao_unicode($codigo_html_site);
// codificando
$dados_gerais_site = retorne_dados_gerais_site($codigo_html_site, $endereco_url_site);
// dados gerais do site
$enderecos_url_site_array = retorna_links_endereco_url($codigo_html_site, $endereco_url_site);
// enderecos url de site
$imagens_site_array_url = retorna_imagens_endereco_url($codigo_html_site, $endereco_url_site);
// imagens do site
$dados_links = separa_dados_obtidos_links_salvar($enderecos_url_site_array);
// dados de links
if (count($dados_links) == 0) {
return null;
// retorno nulo
}
$contador = 0;
// contador
for ($contador == $contador; $contador <= count($dados_links); $contador++) {
$titulo_link_lista .= $dados_links[$contador][0];
// titulos de links
$url_link_lista .= $dados_links[$contador][1];
// titulos de links
}
$contador = 0;
// contador
for ($contador == $contador; $contador <= count($array_links_host_diferente); $contador++) {
$titulo_link_host_diferente_lista .= $dados_links[$contador][0];
// titulos de links
$url_link_host_diferente_lista .= $dados_links[$contador][1];
// titulos de links
}
$dados_imagens = $imagens_site_array_url;
// dados array de imagens
$contador = 0;
// contador
for ($contador == $contador; $contador <= count($dados_imagens); $contador++) {
$dados_array_imagem = $dados_imagens[$contador];
// dados
$imagem_url_lista .= $dados_array_imagem[$contador][0];
// url
$imagem_titulo_lista .= $dados_array_imagem[$contador][1];
// titulo
$imagem_alt_lista .= $dados_array_imagem[$contador][2];
// alt
}
$titulo_site = $dados_gerais_site['title'];
// titulo do site
$url_pagina = $endereco_url_site;
// url da pagina
$descricao_site = $dados_gerais_site['description'];
// descricao do site
$palavras_chave_site = $dados_gerais_site['keywords'];
// palavras chave do site
$host_site = retorna_host_url($endereco_url_site);
// host do site
$tabela_salvar_site = retorne_tabela_salvar_site();
// tabela para salvar o site
$data = date('d:m:y');
// data
$host_site = remove_html($host_site);
// remove codigo especial
$url_pagina = remove_html($url_pagina);
// remove codigo especial
$titulo_site = remove_html($titulo_site);
// remove codigo especial
$palavras_chave_site = remove_html($palavras_chave_site);
// remove codigo especial
$descricao_site = remove_html($descricao_site);
// remove codigo especial
//.........这里部分代码省略.........
开发者ID:GuilhermeFelipe616,项目名称:Altabusca,代码行数:101,代码来源:compilado_php.php
注:本文中的url_get_contents函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论