当前位置: 首页>>代码示例>>PHP>>正文


PHP Webmention::supportsMentions方法代码示例

本文整理汇总了PHP中Idno\Core\Webmention::supportsMentions方法的典型用法代码示例。如果您正苦于以下问题:PHP Webmention::supportsMentions方法的具体用法?PHP Webmention::supportsMentions怎么用?PHP Webmention::supportsMentions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Idno\Core\Webmention的用法示例。


在下文中一共展示了Webmention::supportsMentions方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getFeedDetails

 /**
  * Given the URL of a website, returns a single linked array containing the URL and title of a feed
  * (whether Microformats or RSS / Atom). The function will attempt to discover RSS and Atom feeds in
  * the page if this is an HTML site. Returns false if there is no feed.
  * @param $url
  * @return array|false
  */
 function getFeedDetails($url)
 {
     if (!filter_var($url, FILTER_VALIDATE_URL)) {
         return false;
     }
     $client = new Webservice();
     if ($result = $client->get($url)) {
         $feed = array();
         if (!empty($result['content'])) {
             $feed['webmention'] = Webmention::supportsMentions($url, $result['content']);
             if ($html = @\DOMDocument::loadHTML($result['content'])) {
                 $xpath = new \DOMXpath($html);
                 $title = $xpath->query('//title')->item(0)->nodeValue;
                 if ($xpath->query("//*[contains(concat(' ', @class, ' '), ' h-entry ')]")->length > 0) {
                     $feed['type'] = 'mf2';
                     $feed['url'] = $url;
                     if (!empty($title)) {
                         $feed['title'] = $title;
                     }
                     return $feed;
                 }
                 if ($rss_url = $this->findXMLFeedURL($html)) {
                     $feed['type'] = 'xml';
                     $feed['url'] = $rss_url;
                     if (!empty($title)) {
                         $feed['title'] = $title;
                     }
                     return $feed;
                 }
             }
             if ($xml = @simplexml_load_string($result['content'])) {
                 if (!empty($xml->rss->channel->item) || !empty($xml->feed) || !empty($xml->channel->item)) {
                     $feed['type'] = 'xml';
                     $feed['url'] = $url;
                     if (!empty($xml->rss->channel->title)) {
                         $feed['title'] = $xml->rss->channel->title;
                     } else {
                         if (!empty($xml->channel->title)) {
                             $feed['title'] = $xml->channel->title;
                         } else {
                             if (!empty($xml->title)) {
                                 $feed['title'] = $xml->title;
                             }
                         }
                     }
                     return $feed;
                 }
             }
         }
     }
     return false;
 }
开发者ID:sintoris,项目名称:Known,代码行数:59,代码来源:Reader.php


注:本文中的Idno\Core\Webmention::supportsMentions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。