本文整理汇总了PHP中Idno\Core\Webservice::file_get_contents方法的典型用法代码示例。如果您正苦于以下问题:PHP Webservice::file_get_contents方法的具体用法?PHP Webservice::file_get_contents怎么用?PHP Webservice::file_get_contents使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Idno\Core\Webservice
的用法示例。
在下文中一共展示了Webservice::file_get_contents方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTitleFromURL
/**
* Given a URL, returns the page title.
* @param $Url
* @return mixed
*/
function getTitleFromURL($Url)
{
$str = \Idno\Core\Webservice::file_get_contents($Url);
if (strlen($str) > 0) {
preg_match("/\\<title\\>(.*)\\<\\/title\\>/siu", $str, $title);
return htmlspecialchars_decode($title[1]);
}
return '';
}
示例2: getTitleFromURL
/**
* Given a URL, returns the page title.
* @param $Url
* @return mixed
*/
function getTitleFromURL($Url)
{
$str = \Idno\Core\Webservice::file_get_contents($Url);
//@file_get_contents($Url);
if (strlen($str) > 0) {
preg_match("/\\<title\\>(.*)\\<\\/title\\>/i", $str, $title);
return $title[1];
}
return '';
}
示例3: findSelf
/**
* Find the self resource.
* This method will find a link self on a feed, finding the feed first
* @param type $url
*/
private function findSelf($url)
{
$self = null;
$feed = null;
// Find RSS
$feed = $this->findFeed($url);
// Find self
if ($feed) {
$data = \Idno\Core\Webservice::file_get_contents($feed);
if (preg_match('/<atom:link[^>]+href="([^"]+)"[^>]*rel="self"[^>]*>/i', $data, $match)) {
$self = $match[1];
}
if (preg_match('/<atom:link[^>]+rel="self"[^>]*href="([^"]+)"[^>]*>/i', $data, $match)) {
$self = $match[1];
}
}
return $self;
}
示例4: addWebmentionItem
/**
* Recursive helper function for parsing webmentions.
*
* @param $item
* @param $mentions
* @return array
*/
function addWebmentionItem($item, $mentions, $source, $target, $title = '')
{
if (!empty($item['properties']['author'])) {
foreach ($item['properties']['author'] as $author) {
if (!empty($author['type'])) {
foreach ($author['type'] as $type) {
if ($type == 'h-card') {
if (!empty($author['properties']['name'])) {
$mentions['owner']['name'] = $author['properties']['name'][0];
}
if (!empty($author['properties']['url'])) {
$mentions['owner']['url'] = $author['properties']['url'][0];
}
if (!empty($author['properties']['photo'])) {
//$mentions['owner']['photo'] = $author['properties']['photo'][0];
$tmpfname = tempnam(sys_get_temp_dir(), 'webmention_avatar');
file_put_contents($tmpfname, \Idno\Core\Webservice::file_get_contents($author['properties']['photo'][0]));
$name = md5($author['properties']['url'][0]);
// TODO: Don't update the cache image for every webmention
if ($icon = \Idno\Entities\File::createThumbnailFromFile($tmpfname, $name, 300)) {
$mentions['owner']['photo'] = \Idno\Core\Idno::site()->config()->url . 'file/' . (string) $icon;
} else {
if ($icon = \Idno\Entities\File::createFromFile($tmpfname, $name)) {
$mentions['owner']['photo'] = \Idno\Core\Idno::site()->config()->url . 'file/' . (string) $icon;
}
}
unlink($tmpfname);
}
}
}
}
}
}
if (!empty($item['type'])) {
if (in_array('h-entry', $item['type'])) {
$mention = array();
if (!empty($item['properties'])) {
if (!empty($item['properties']['content'])) {
$mention['content'] = '';
if (is_array($item['properties']['content'])) {
foreach ($item['properties']['content'] as $content) {
if (!empty($content['value'])) {
$parsed_content = \Idno\Core\Idno::site()->template()->sanitize_html($content['value']);
if (!substr_count($mention['content'], $parsed_content)) {
$mention['content'] .= $parsed_content;
}
}
}
} else {
$mention['content'] = $item['properties']['content'];
}
} else {
if (!empty($item['properties']['summary'])) {
if (is_array($item['properties']['summary'])) {
$mention['content'] = \Idno\Core\Idno::site()->template()->sanitize_html(implode(' ', $item['properties']['summary']));
} else {
$mention['content'] = $item['properties']['summary'];
}
} else {
if (!empty($item['properties']['name'])) {
if (is_array($item['properties']['name'])) {
$mention['content'] = \Idno\Core\Idno::site()->template()->sanitize_html(implode(' ', $item['properties']['name']));
} else {
$mention['content'] = $item['properties']['name'];
}
}
}
}
if (!empty($item['properties']['published'])) {
if (is_array($item['properties']['published'])) {
$mention['created'] = @strtotime(array_shift(array_pop($item['properties']['published'])));
} else {
$mention['created'] = @strtotime($item['properties']['content']);
}
}
if (empty($mention['created'])) {
$mention['created'] = time();
}
if (!empty($item['properties']['url'])) {
if (!empty($item['properties']['uid'])) {
$mention['url'] = array_intersect($item['properties']['uid'], $item['properties']['url']);
}
if (empty($mention['url'])) {
$mention['url'] = $item['properties']['url'];
}
}
if (!empty($item['properties']['like']) && is_array($item['properties']['like'])) {
if (in_array($target, static::getStringURLs($item['properties']['like']))) {
$mention['type'] = 'like';
}
}
if (!empty($item['properties']['like-of']) && is_array($item['properties']['like-of'])) {
if (in_array($target, static::getStringURLs($item['properties']['like-of']))) {
//.........这里部分代码省略.........
示例5: getIconFromWebsiteContent
/**
* Retrieve a user's icon from a given homepage
* @param $content The content of the page
* @param $url The URL of the page
* @return $icon_url
*/
static function getIconFromWebsiteContent($content, $url)
{
if ($mf2 = self::parseContent($content, $url)) {
$mf2 = (array) $mf2;
foreach ($mf2['items'] as $item) {
// Figure out what kind of Microformats 2 item we have
if (!empty($item['type']) && is_array($item['type'])) {
foreach ($item['type'] as $type) {
switch ($type) {
case 'h-card':
if (!empty($item['properties'])) {
if (!empty($item['properties']['name'])) {
$mentions['owner']['name'] = $item['properties']['name'][0];
}
if (!empty($item['properties']['url'])) {
$mentions['owner']['url'] = $item['properties']['url'][0];
}
if (!empty($item['properties']['photo'])) {
//$mentions['owner']['photo'] = $item['properties']['photo'][0];
$tmpfname = tempnam(sys_get_temp_dir(), 'webmention_avatar');
file_put_contents($tmpfname, \Idno\Core\Webservice::file_get_contents($item['properties']['photo'][0]));
$name = md5($item['properties']['url'][0]);
// TODO: Don't update the cache image for every webmention
if ($icon = \Idno\Entities\File::createThumbnailFromFile($tmpfname, $name, 300)) {
return \Idno\Core\Idno::site()->config()->url . 'file/' . (string) $icon;
} else {
if ($icon = \Idno\Entities\File::createFromFile($tmpfname, $name)) {
return \Idno\Core\Idno::site()->config()->url . 'file/' . (string) $icon;
}
}
unlink($tmpfname);
}
}
break;
}
}
}
}
}
return false;
}
示例6: parseHCard
private function parseHCard($hcard)
{
$owner = [];
if (!empty($hcard['properties']['name'])) {
$owner['name'] = $hcard['properties']['name'][0];
}
if (!empty($hcard['properties']['url'])) {
$owner['url'] = $hcard['properties']['url'][0];
}
if (!empty($hcard['properties']['photo'])) {
//$owner['photo'] = $hcard['properties']['photo'][0];
$tmpfname = tempnam(sys_get_temp_dir(), 'webmention_avatar');
file_put_contents($tmpfname, \Idno\Core\Webservice::file_get_contents($hcard['properties']['photo'][0]));
$name = md5($hcard['properties']['url'][0]);
// TODO: Don't update the cache image for every webmention
if ($icon = \Idno\Entities\File::createThumbnailFromFile($tmpfname, $name, 300)) {
$owner['photo'] = \Idno\Core\Idno::site()->config()->url . 'file/' . (string) $icon;
} else {
if ($icon = \Idno\Entities\File::createFromFile($tmpfname, $name)) {
$owner['photo'] = \Idno\Core\Idno::site()->config()->url . 'file/' . (string) $icon;
}
}
unlink($tmpfname);
}
return $owner;
}