承接 zegnat/webmention-endpoint-discovery 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

zegnat/webmention-endpoint-discovery

Composer 安装命令:

composer require zegnat/webmention-endpoint-discovery

包简介

A straight forward implementation of webmention endpoint discovery.

README 文档

README

Mostly a thought experiment to see what exactly is required to do Webmention endpoints discovery. You can use this implementation on its own, though it will probably net you better results to tightly integrate the code within the rest of your application.

Under the licence of this project you should feel free to copy any parts of it that you want to take for inspiration! Not even attribution is required – even when appreciated.

Install

Via Composer

$ composer require zegnat/webmention-endpoint-discovery

Usage

$discoverer = new Zegnat\Webmention\EndpointDiscovery($httpClient, $requestFactory);
echo $discoverer->discover('https://webmention.rocks/test/1');
// https://webmention.rocks/test/1/webmention\?head=true
  • $httpClient must be an implementation of HttpClient as defined by HTTPlug. This will (hopefully soon) be replaced with PSR-18.
  • $requestFactory must be an implementation of RequestFactoryInterface as defined by PHP-FIG as PSR-17.

Secure Endpoints

NOTE: This feature is very much experimental. Please consult the code before deciding to use it.

There might be some weird issues triggered by having Webmention senders post mentions to things on their local machines. The Webmention specification calls on senders to avoid sending Webmentions to localhost. This library enables that.

EndpointDiscovery::secureDiscover will return null not only when no endpoint could be found, but also when the found endpoint’s host’s DNS resolves to an IP address in the private or reserved range. When all the IP addresses found are deemed to be OK, the method will return an array as follows:

$discoverer = new Zegnat\Webmention\EndpointDiscovery($httpClient, $requestFactory);
var_export($discoverer->secureDiscover('https://webmention.rocks/test/1'));
// array (
//   'url' => 'https://webmention.rocks/test/1/webmention?head=true',
//   'host' => 'webmention.rocks',
//   'ips' =>
//   array (
//     0 => '173.230.155.197',
//   ),
// )

It is recommended that the Webmention sender uses this information for posting the mention. Use one of the checked IP addresses to post to (instead of the domain, which might redo the DNS lookup) with the host in a Host HTTP header.

Testing

For quick testing without logging, coverage reports, or live calls to Webmention Rocks!:

$ composer test -- --no-logging --no-coverage --exclude-group internet

Else:

$ composer test

统计信息

  • 总下载量: 11
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: 0BSD
  • 更新时间: 2018-08-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固