GithubHelp home page GithubHelp logo

indieweb / mention-client-php Goto Github PK

View Code? Open in Web Editor NEW
95.0 16.0 19.0 472 KB

Client library for sending webmention and pingback notifications

Home Page: https://indieweb.org/webmention

PHP 6.72% HTML 93.03% CSS 0.25%
webmention pingback indieweb

mention-client-php's People

Contributors

aaronpk avatar benwerd avatar hongpong avatar kylewm avatar mapkyca avatar marcusjfloyd avatar pfefferle avatar singpolyma avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mention-client-php's Issues

Problems with parse_headers function

I had a look at your tests where you use something like:

Link: <http://aaronparecki.com/webmention.php>; rel=\"http://webmention.org/\"\r
Link: <http://aaronparecki.com/>; rel=\"me\"";

...but as far as I know, headers will be sent like this:

Link: <http://aaronparecki.com/webmention.php>; rel=\"http://webmention.org/\",<http://aaronparecki.com/>; rel=\"me\""

Incorrectly matches an endpoint inside an HTML comment

The parser is incorrectly finding a webmention endpoint that is commented out in HTML:

    <!--
    <a rel="webmention" href="http://webmention.example/wrong"></a>
    -->
    <a rel="webmention" href="http://webmention.example/correct"></a>

Find links in canonical mf2 object

Currently the findOutgoingLinks function naively looks only at the first mf2 object in items.

Here is the proposed solution:

Add a parameter to findOutgoingLinks that accepts the source URL of the page. For each item in the mf2 items, look for the item with a url property that matches the URL given. If none is found, defaulting to the first item is fine.

This works under the assumption that this function will only be used for sending webmentions for post permalinks, as this will not work for feed pages that contain multiple h-entrys (although it will work for a feed page that uses h-feed).

findOutgoingLinks method should return only URLs in <a> tags

Currently the findOutgoingLinks method will return any mf2 property that is a URL, regardless of the element the value came from. For example, <data class="u-in-reply-to" value="http://example.com/"> will be considered a link, even though according to HTML it is not a link. This is a problem because sending a webmention to that URL will fail when its webmention endpoint tries to look for a link back.

findOutgoingLinks doesn't work when a h-card is present

I have my posts marked up with microformats2:

<article class="h-entry">
    <div>
        <div>
            <p class="title">
                <i class="fa-solid fa-reply"></i> replied to 
                <a class="u-in-reply-to" href="https://micro.geheimesite.nl/post/626f9d9c0e367">https://micro.geheimesite.nl/post/626f9d9c0e367</a>
            </p>
            <div class="p-summary e-content">
                <p>The only thing I still need to do now is add support for webmention comments (which I'm testing now) and add a media endpoint for photo posts. I think the comments should be working now; this is a test :)</p>
            </div>
        </div>           

        <a class="no-underline u-url" href="https://micro.geheimesite.nl/post/626fca88eb951">
            <time class="dt-published">2022-05-02 14:11:52</time>
        </a>
    </div>            
    <div class="p-author h-card">
        <img src="/assets/me.jpeg" class="u-photo">
        <p hidden=""><a class="u-url p-name" href="https://micro.geheimesite.nl">Robijntje</a></p>
    </div>        
</article>

They include an h-card. Currently findOutgoingLinks doesn't work with this setup, because it only checks the first element in the array returned by the mf2 parser, which is the h-card. I think a possible solution is using a foreach loop and just checking all elements in the array and picking the one with type=h-entry.

I'm pretty sure my mf2 markup is fine, but if it isn't, let me know :)

Please re-license or dual license to MIT

This is easier to do before there are many contributors.

IMO, the best would be if libs like this one eventually became bundled in FLOSS PHP apps and this is easier with the MIT license than the Apache license. I was part of a group that worked hard to change the Bootstrap license from Apache to MIT for easy inclusion in GPL/LGPL apps: twbs/bootstrap#2054

In my case, it's to include in Tiki Wiki CMS Groupware, in the context of WikiSuite, for which IndieWeb is an inspiration.
https://tiki.org/ -> Tiki is the Free/Libre/Open Source Web Application with the most built-in features
https://tiki.org/License
http://wikisuite.org/ -> WikiSuite is the most comprehensive and integrated Free / Libre / Open Source software suite ever developed.
http://wikisuite.org/Component-criteria#IndieWeb

Thanks!

implode(): Passing glue string after array is deprecated

On PHP 7.4 and up, the implode() arguments should probably be presented in the same order as they would for explode(). Earlier PHP versions accept either order, so the change would be backward compatible.

PHP Deprecated:  implode(): Passing glue string after array is deprecated. Swap the parameters in [...]/IndieWeb/MentionClient.php on line 224

requires xmlrpc module

The call to xmlrpc_decode failed on vanilla Ubuntu because I did not have the php5-xmlrpc module installed (Debian-derived distros at least seem to break less common stdlib functions into separate modules)

I think it would be worthwhile to make this a soft requirement (check for existence of the function before calling it) or remove it altogether and verify the response manually, since pingback is kind of secondary and we're not doing much with the response anyway.

mb_convert_encoding(): Argument #3 ($from_encoding) must specify at least one encoding

I'm using the 'sendMentions()' method (using PHP 8.1), and while it does seem to be sending the Webmentions, it terminates in a 500 error:

CRITICAL - 2023-10-13 17:09:19 --> mb_convert_encoding(): Argument #3 ($from_encoding) must specify at least one encoding in VENDORPATH/mf2/mf2/Mf2/Parser.php on line 96. 1 VENDORPATH/mf2/mf2/Mf2/Parser.php(96): mb_convert_encoding() 2 VENDORPATH/mf2/mf2/Mf2/Parser.php(365): Mf2\unicodeToHtmlEntities() 3 VENDORPATH/indieweb/mention-client/src/IndieWeb/MentionClient.php(156): Mf2\Parser->__construct() 4 VENDORPATH/indieweb/mention-client/src/IndieWeb/MentionClient.php(240): IndieWeb\MentionClient->_parseBody() 5 VENDORPATH/indieweb/mention-client/src/IndieWeb/MentionClient.php(418): IndieWeb\MentionClient->discoverWebmentionEndpoint() 6 VENDORPATH/indieweb/mention-client/src/IndieWeb/MentionClient.php(400): IndieWeb\MentionClient->sendFirstSupportedMention() 7 APPPATH/Controllers/Blogpost.php(24): IndieWeb\MentionClient->sendMentions() ...

Am I doing something wrong, or is this a bug?

Doesn't handle safe mode or open_basedir

Basically, curl does some odd things in many hosted environments where basedir or safe mode are set - namely, CURLOPT_FOLLOWLOCATION is disabled... for some reason.

This causes problems on a number of hosts where this is enabled by default.

@benwerd's solution was to implement this in code, but that's not pretty in a library context. Perhaps having the ability to pass a send function to hand off to might be a way to go? I can of course just subclass...

(Refs idno/known#629)

webemntion.io

Maybe mention webemtnion.io as an alternative to pingback.me, particularly as pingback -> webmention proxy service.

xmlrpc_decode returns null on successful pingback response in sendPingback() method in php 5.5.11

xmlrpc_decode returns null in php 5.5.11 when the pingback response is a string which indicates a successful pingback response. I looked at the xlmrpc_decode method at php.net and realized that this method cannot be trusted: http://us1.php.net/manual/en/function.xmlrpc-decode.php

In the sendPingback() method we have:

if(@$decoded=xmlrpc_decode($response)) {
  if(is_string($decoded))
    return true; // pingback returns a string like "Pingback was successful" when it works
  else
    return false; // otherwise returns an array like array('faultCode'=>48,'faultString'=>'The pingback has already been registered')
} else {
  return false;
}

Since $decoded is null on a successful pingback, the method will return false even though we got a successful response from the pingback target.

The following conditional block which replaces the block of code above solves the problem for everyone I believe:

if(is_array(xmlrpc_decode($response))):
    return false;
elseif(is_string($response) && !empty($response)): 
    return true;
endif;

Pretty much it checks if xmlrpc_decode returns an array signifying we got an xml response which means you have an error, else if you get a non empty string then it's a success.

I hope this helped. Thanks for this library by the way. I'm in the middle of making my own blog for my website and this saved a lot of time.

Call to $client->sendSupportedMentions() not functioning correctly

When I send a webmention from http://django.bnvk.me/notes/19 (varied availability) which links to http://waterpigs.co.uk/notes/4QbH5C/ it fails with this 301 error

Checking http://django.bnvk.me/ Fetching headers... No webmention server found in header, looking in the body now Fetching body... webmention server: http://webmention.io/brennannovak.com/webmention Sending webmention now! Sending to webmention server: http://webmention.io/brennannovak.com/webmention

301 Moved Permanently

Barnaby manually submitted my comment on his site and it worked just fine so wesathinks is has something do with the regex in the client

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.