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


PHP Webservice::head方法代码示例

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


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

示例1: getContent

 function getContent()
 {
     $this->gatekeeper();
     $url = $this->getInput('share_url', $this->getInput('url'));
     $title = $this->getInput('share_title', $this->getInput('title'));
     $type = $this->getInput('share_type');
     $syndicatedto = [];
     // remove cruft added by mobile apps
     if (preg_match('~\\b(?:f|ht)tps?://[^\\s]+\\b~i', $url, $matches)) {
         $url = $matches[0];
     }
     $event = new \Idno\Core\Event();
     $event->setResponse($url);
     \Idno\Core\Idno::site()->events()->dispatch('url/shorten', $event);
     $short_url = $event->response();
     if (!$type || !\Idno\Common\ContentType::getRegisteredForIndieWebPostType($type)) {
         $share_type = 'note';
         // Probe to see if this is something we can MF2 parse, before we do
         $headers = [];
         if ($head = \Idno\Core\Webservice::head($url)) {
             $headers = http_parse_headers($head['header']);
         }
         // Only MF2 Parse supported types
         if (isset($headers['Content-Type']) && preg_match('/text\\/(html|plain)+/', $headers['Content-Type'])) {
             if ($response = \Idno\Core\Webservice::get($url)) {
                 if ($mf2 = \Idno\Core\Webmention::parseContent($response['content'])) {
                     if (!empty($mf2['items'])) {
                         foreach ($mf2['items'] as $item) {
                             if (!empty($item['type'])) {
                                 if (in_array('h-entry', $item['type'])) {
                                     $share_type = 'reply';
                                 }
                                 if (in_array('h-event', $item['type'])) {
                                     $share_type = 'rsvp';
                                 }
                             }
                         }
                     }
                 }
                 $syndicatedto = \Idno\Core\Webmention::addSyndicatedReplyTargets($url, $syndicatedto, $response);
             }
         }
     } else {
         $share_type = $type;
     }
     $content_type = \Idno\Common\ContentType::getRegisteredForIndieWebPostType($share_type);
     $hide_nav = false;
     if ($this->getInput('via') == 'ff_social') {
         $hide_nav = true;
     }
     if (!empty($content_type)) {
         if ($page = \Idno\Core\Idno::site()->getPageHandler($content_type->getEditURL())) {
             if ($share_type == 'note') {
                 $page->setInput('body', $title . ' ' . $short_url);
             } else {
                 $page->setInput('short-url', $short_url);
                 $page->setInput('url', $url);
                 $page->setInput('syndicatedto', $syndicatedto);
                 // prefill the @-name of the person we're replying to
                 $atusers = [];
                 foreach (array_merge((array) $url, (array) $syndicatedto) as $tweeturl) {
                     if (strstr($tweeturl, 'twitter.com') !== false) {
                         if (preg_match("|https?://([a-z]+\\.)?twitter\\.com/(#!/)?@?([^/]*)|", $tweeturl, $matches) && !empty($matches[3])) {
                             $atusers[] = '@' . $matches[3];
                         }
                         if (preg_match_all("|@([^\\s^\\)]+)|", $title, $matches)) {
                             $atusers = array_merge($atusers, $matches[0]);
                         }
                     }
                 }
                 if ($atusers) {
                     // See if one of your registered twitter handles is present, if so remove it.
                     $user = \Idno\Core\Idno::site()->session()->currentUser();
                     if (!empty($user->twitter) && is_array($user->twitter)) {
                         $me = [];
                         foreach ($user->twitter as $k => $v) {
                             $me[] = '@' . $k;
                         }
                         $atusers = array_diff($atusers, $me);
                     }
                 }
                 if ($atusers) {
                     $atusers = array_unique($atusers);
                     $page->setInput('body', implode(' ', $atusers) . ' ');
                 }
             }
             $page->setInput('hidenav', $hide_nav);
             $page->setInput('sharing', true);
             $page->setInput('share_type', $share_type);
             $page->get();
         }
     } else {
         $t = \Idno\Core\Idno::site()->template();
         $body = $t->__(array('share_type' => $share_type, 'content_type' => $content_type, 'sharing' => true))->draw('entity/share');
         $t->__(array('title' => 'Share', 'body' => $body, 'hidenav' => $hide_nav))->drawPage();
     }
 }
开发者ID:smartboyathome,项目名称:Known,代码行数:97,代码来源:Share.php

示例2: getContent

 function getContent()
 {
     $this->gatekeeper();
     $url = $this->getInput('share_url', $this->getInput('url'));
     $title = $this->getInput('share_title', $this->getInput('title'));
     $type = $this->getInput('share_type');
     $event = new \Idno\Core\Event();
     $event->setResponse($url);
     \Idno\Core\site()->events()->dispatch('url/shorten', $event);
     $short_url = $event->response();
     if (!in_array($type, array('note', 'reply', 'rsvp', 'like', 'bookmark'))) {
         $share_type = 'note';
         // Probe to see if this is something we can MF2 parse, before we do
         $headers = [];
         if ($head = \Idno\Core\Webservice::head($url)) {
             $headers = http_parse_headers($head['header']);
         }
         // Only MF2 Parse supported types
         if (preg_match('/text\\/(html|plain)+/', $headers['Content-Type'])) {
             if ($content = \Idno\Core\Webservice::get($url)) {
                 if ($mf2 = \Idno\Core\Webmention::parseContent($content['content'])) {
                     if (!empty($mf2['items'])) {
                         foreach ($mf2['items'] as $item) {
                             if (!empty($item['type'])) {
                                 if (in_array('h-entry', $item['type'])) {
                                     $share_type = 'reply';
                                 }
                                 if (in_array('h-event', $item['type'])) {
                                     $share_type = 'rsvp';
                                 }
                             }
                         }
                     }
                 }
             }
         }
     } else {
         $share_type = $type;
     }
     $content_type = \Idno\Common\ContentType::getRegisteredForIndieWebPostType($share_type);
     $hide_nav = false;
     if ($this->getInput('via') == 'ff_social') {
         $hide_nav = true;
     }
     if (!empty($content_type)) {
         if ($page = \Idno\Core\site()->getPageHandler('/' . $content_type->camelCase($content_type->getEntityClassName()) . '/edit')) {
             if ($share_type == 'note') {
                 $page->setInput('body', $title . ' ' . $short_url);
             } else {
                 $page->setInput('short-url', $short_url);
                 $page->setInput('url', $url);
                 if (substr_count($url, 'twitter.com')) {
                     $atusers = [];
                     preg_match("|https?://([a-z]+\\.)?twitter\\.com/(#!/)?@?([^/]*)|", $url, $matches);
                     if (!empty($matches[3])) {
                         $atusers[] = '@' . $matches[3];
                         //                                    $page->setInput('body', '@' . $matches[3] . ' ');
                     }
                     if (preg_match_all("|@([^\\s^\\)]+)|", $title, $matches)) {
                         $atusers = array_merge($atusers, $matches[0]);
                     }
                     // See if one of your registered twitter handles is present, if so remove it.
                     $user = \Idno\Core\site()->session()->currentUser();
                     if (!empty($user->twitter) && is_array($user->twitter)) {
                         $me = [];
                         foreach ($user->twitter as $k => $v) {
                             $me[] = "@{$k}";
                         }
                         $atusers = array_diff($atusers, $me);
                     }
                     $atusers = array_unique($atusers);
                     $page->setInput('body', implode(' ', $atusers) . ' ');
                 }
             }
             $page->setInput('hidenav', $hide_nav);
             $page->setInput('sharing', true);
             $page->setInput('share_type', $share_type);
             $page->get();
         }
     } else {
         $t = \Idno\Core\site()->template();
         $body = $t->__(array('share_type' => $share_type, 'content_type' => $content_type, 'sharing' => true))->draw('entity/share');
         $t->__(array('title' => 'Share', 'body' => $body, 'hidenav' => $hide_nav))->drawPage();
     }
 }
开发者ID:emory,项目名称:Known,代码行数:85,代码来源:Share.php


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