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


PHP Webmention::getPageContent方法代码示例

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


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

示例1: post

 function post()
 {
     parse_str(trim(file_get_contents("php://input")), $vars);
     // Check that both source and target are non-empty
     if (!empty($vars['source']) && !empty($vars['target']) && $vars['source'] != $vars['target']) {
         $source = urldecode($vars['source']);
         $target = urldecode($vars['target']);
         // Get the page handler for target
         if ($page = \Idno\Core\site()->getPageHandler($target)) {
             // Check that source exists, parse it for mf2 content,
             // and ensure that it genuinely mentions this page
             if ($source_content = \Idno\Core\Webmention::getPageContent($source)) {
                 if (substr_count($source_content['content'], $target) || $source_content['response'] == 410) {
                     $source_mf2 = \Idno\Core\Webmention::parseContent($source_content['content']);
                     // Set source and target information as input variables
                     $page->setPermalink();
                     if ($page->webmentionContent($source, $target, $source_content, $source_mf2)) {
                         $this->setResponse(202);
                         // Webmention received a-ok.
                         exit;
                     } else {
                         $error = 'target_not_supported';
                         $error_text = 'This is not webmentionable.';
                     }
                 } else {
                     $error = 'no_link_found';
                     $error_text = 'The source URI does not contain a link to the target URI.';
                     error_log('No link from ' . $source . ' to ' . $target);
                 }
             } else {
                 $error = 'source_not_found';
                 $error_text = 'The source content could not be obtained.';
                 error_log('No content from ' . $source);
             }
         } else {
             $error = 'target_not_found';
             $error_text = 'The target page does not exist.';
         }
     }
     $this->setResponse(400);
     // Webmention failed.
     echo json_encode(['error' => $error, 'error_text' => $error_text]);
 }
开发者ID:phpsource,项目名称:idno,代码行数:43,代码来源:Endpoint.php

示例2: getContent

 function getContent()
 {
     if (!\Idno\Core\site()->session()->isLoggedIn()) {
         $this->setResponse(401);
         $this->forward('/session/login');
     }
     $url = $this->getInput('share_url');
     $title = $this->getInput('share_title');
     $share_type = 'note';
     if ($content = \Idno\Core\Webmention::getPageContent($url)) {
         if ($mf2 = \Idno\Core\Webmention::parseContent($content['content'])) {
             if (substr_count($content['content'], 'h-entry') == 1) {
                 $share_type = 'reply';
                 if (substr_count($content['content'], 'h-event') == 1) {
                     $share_type = 'rsvp';
                 }
             }
         }
     }
     $content_type = \Idno\Common\ContentType::getRegisteredForIndieWebPostType($share_type);
     if (!empty($content_type)) {
         if ($page = \Idno\Core\site()->getPageHandler('/' . $content_type->camelCase($content_type->getEntityClassName()) . '/edit')) {
             if ($share_type == 'note' && !substr_count($url, 'twitter.com')) {
                 $page->setInput('body', $title . ' ' . $url);
             } else {
                 $page->setInput('url', $url);
                 if (substr_count($url, 'twitter.com')) {
                     preg_match("|https?://(www\\.)?twitter\\.com/(#!/)?@?([^/]*)|", $url, $matches);
                     if (!empty($matches[3])) {
                         $page->setInput('body', '@' . $matches[3] . ' ');
                     }
                 }
             }
             $page->setInput('hidenav', true);
             $page->get();
         }
     } else {
         $t = \Idno\Core\site()->template();
         $body = $t->__(['share_type' => $share_type, 'content_type' => $content_type])->draw('firefox/share');
         $t->__(['title' => 'Share', 'body' => $body, 'hidenav' => true])->drawPage();
     }
 }
开发者ID:phpsource,项目名称:idno,代码行数:42,代码来源:Share.php


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