Giter Site home page Giter Site logo

Comments (46)

aaronpk avatar aaronpk commented on May 20, 2024 1

Hi! I was away from my computer the last 2 days, just catching up now. Now that you mention it, I do remember hearing about some web servers removing the Authorization header. It could be either the web server or a proxy server in between.

It looks like for Apache, some people are having luck adding this line to their .htaccess file:

SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1

If that doesn't solve it, or if the host isn't using Apache, you'll need to contact someone there to ask how to allow the header through.

from wordpress-micropub.

tamaracks avatar tamaracks commented on May 20, 2024 1

You're probably right. I'm a little surprised there doesn't seem to be one already, but if there is I can't find it. I am trying my hand at writing one. It should be fairly simple, and I think I found something that gives me a starting point, but I don't know anything about writing a Wordpress plugin, so the data passed into it and where to hook in are the tricky part. It could all end in tears. 😉

Personally, it's really just title-less posts that I am concerned about, because if given the right format (and depending on the theme), you can refrain from displaying a title at all, rather than WP showing a title with the post ID. The problem with using an mf2 property is that you're depending on the source of the submission. If you can control it, that's great, but when it comes to an external source, like OwnYourSwarm, or perhaps a client that doesn't support it, that's harder.

from wordpress-micropub.

snarfed avatar snarfed commented on May 20, 2024

thanks for filing, and sorry for the trouble!

can you check if OwnYourSwarm is passing an auth token in its HTTP request, in either the Authorization HTTP header or the access_token parameter? the missing access token error comes from here, which implies that it's not sending either of those. cc @aaronpk.

from wordpress-micropub.

tamaracks avatar tamaracks commented on May 20, 2024

Is there any way I can see that? I checked the access and error logs on my server, but I don't seem to see anything about such a request. Or is that something I would need to ask @aaronpk?

from wordpress-micropub.

snarfed avatar snarfed commented on May 20, 2024

sure! if OwnYourSwarm includes the token in the request body, put define('WP_DEBUG', true); define('WP_DEBUG_LOG', true); in your wp-config.php, and the plugin will log full request bodies to wp-content/debug.log, including the token.

if OwnYourSwarm uses the Authorization header instead...the plugin doesn't have a good way to log that right now.

@aaronpk usually includes good debugging features in his projects. i suspect OwnYourSwarm might have a way to see its own full micropub requests...?

from wordpress-micropub.

tamaracks avatar tamaracks commented on May 20, 2024

When I turn on the debug option and have ownyourswarm try again, I get this:

[03-May-2017 15:42:30 UTC] Micropub Data: a:1:{s:8:"micropub";s:8:"endpoint";} a:2:{s:4:"type";a:1:{i:0;s:7:"h-entry";}s:10:"properties";a:4:{s:9:"published";a:1:{i:0;s:25:"2017-05-02T20:00:12-04:00";}s:11:"syndication";a:1:{i:0;s:70:"https://www.swarmapp.com/user/1133595/checkin/59091d8ca35dce27dec0d29a";}s:7:"content";a:1:{i:0;s:44:"Rats, no protein boxes. Or any bistro boxes.";}s:7:"checkin";a:1:{i:0;a:2:{s:4:"type";a:1:{i:0;s:6:"h-card";}s:10:"properties";a:10:{s:4:"name";a:1:{i:0;s:9:"Starbucks";}s:3:"url";a:3:{i:0;s:49:"https://foursquare.com/v/4b9d0793f964a520b98936e3";i:1;s:37:"http://www.starbucks.com/store/10595/";i:2;s:29:"https://twitter.com/starbucks";}s:3:"tel";a:1:{i:0;s:14:"(973) 248-8260";}s:8:"latitude";a:1:{i:0;d:41.00777034;}s:9:"longitude";a:1:{i:0;d:-74.292899770000005;}s:14:"street-address";a:1:{i:0;s:17:"45 Wanaque Avenue";}s:8:"locality";a:1:{i:0;s:13:"Pompton Lakes";}s:6:"region";a:1:{i:0;s:2:"NJ";}s:12:"country-name";a:1:{i:0;s:13:"United States";}s:11:"postal-code";a:1:{i:0;s:5:"07442";}}}}}}
[03-May-2017 15:42:30 UTC] PHP Notice:  Undefined index: authorization in /home/public/wp-content/plugins/micropub/micropub.php on line 892
[03-May-2017 15:42:30 UTC] PHP Notice:  Undefined index: access_token in /home/public/wp-content/plugins/micropub/micropub.php on line 157
[03-May-2017 15:42:30 UTC] PHP Warning:  Cannot modify header information - headers already sent by (output started at /home/public/wp-content/plugins/micropub/micropub.php:892) in /home/public/wp-content/plugins/micropub/micropub.php on line 881

I am guessing that doesn't say anything we didn't already know.

The ownyourswarm doc page says this:

Once OwnYourSwarm has obtained an access token, it will send it along with each request in an HTTP Authorization header like the below.

HTTP/1.1 POST /micropub
Authorization: Bearer xxxxxxxxxxxxxxxxxxxxxxx

I don't believe there is anything else on the OwnYourSwarm page about the entire request sent. There's the home page, with a brief description, the Dashboard, which has the information I pasted to you earlier, and the Docs page, which has a bit about how to set up indieauth, the part I pasted above, and some more information about the kind of data it sends after auth.

I see from his web site that @aaronpk looks to be attending a conference, so that may be why I haven't gotten any further replies from him on the issue I put in on that project (aaronpk/OwnYourSwarm#16). His initial reply said he checked the logs, but I'm not sure which logs.

from wordpress-micropub.

snarfed avatar snarfed commented on May 20, 2024

thanks for the detail from their docs! looks like the Authorization header is getting lost somewhere between OwnYourSwarm sending it and this plugin receiving it.

here's where the plugin looks it up:
https://github.com/snarfed/wordpress-micropub/blob/676ef39c405a9c13eeec9af3325b8b714e20043b/micropub.php#L156 , via https://github.com/snarfed/wordpress-micropub/blob/676ef39c405a9c13eeec9af3325b8b714e20043b/micropub.php#L884-L893 and https://github.com/snarfed/wordpress-micropub/blob/676ef39c405a9c13eeec9af3325b8b714e20043b/micropub.php#L906-L921 .

@tamaracks, any chance your web server or hosting provider are stripping the Authorization header? also, could you tell me the versions of PHP and WordPress you're using?

from wordpress-micropub.

tamaracks avatar tamaracks commented on May 20, 2024

WordPress 4.7.4

Running php -v from the command line on my host gets

PHP 7.1.4-nfsn1 (cli) (built: Apr 26 2017 23:19:00) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies

As for the host stripping the header, that's a good question, but I am not sure. I did find a thread on the member support forum where a similar question was asked:
NearlyFreeSpeech.NET -- View topic - Stripped Authorization headers (?).pdf

(The user jdw is one of the people who runs the NearlyFreeSpeech hosting service.)

But that thread is from 2015, so I don't know if the answer is still pertinent. And I am not quite sure how to interpret the answer (maybe it will make more sense to you).

from wordpress-micropub.

tamaracks avatar tamaracks commented on May 20, 2024

Oh, and this is the result of creating a php web page on my site that outputs phpinfo(). I was trying to remember how to get that.

As PDF

Zipped copy of the HTML output from the browser

from wordpress-micropub.

tamaracks avatar tamaracks commented on May 20, 2024

I can switch my web site between PHP 5.6 and 7.1 on my host's admin panel. I tried 7.1, but it didn't seem to make a difference in the result for this case (didn't seem to break anything with WordPress either yet, so that's good).

I have to step away from my keyboard for a while now, but if you have any other suggestions of what I can try, I'll be happy to do so when I get back. I can submit a question on the host's member forum if you think it would help.

from wordpress-micropub.

snarfed avatar snarfed commented on May 20, 2024

thanks for all the info!

based on all of this, i still do suspect the Authorization header is getting stripped somewhere. mind trying another experiment? try inserting this at line 126 of wp-content/plugins/wordpress-micropub/micropub.php, right after the other error_log(... line:

error_log( 'Micropub HTTP headers: ' . serialize( getallheaders() ) );

...then get OwnYourSwarm to try again and see if the Authorization header shows up in wp-content/debug.log.

from wordpress-micropub.

tamaracks avatar tamaracks commented on May 20, 2024

I tried that htaccess command, @aaronpk, but no dice, alas. The webserver is Apache, afaict.

@snarfed, I did try the extra debugging. Output below.

The first block was after I started debugging, but it appeared that the site-icon-extended plugin might have been getting in the way. I deactivated it, and tried again, so this first set of logs may not be so useful, but I included it just in case.

[04-May-2017 23:00:51 UTC] PHP Deprecated:  Methods with the same name as their class will not be constructors in a future version of PHP; PHP_ICO has a deprecated constructor in /home/public/wp-content/plugins/site-icon-extended/vendor/chrisbliss18/php-ico/class-php-ico.php on line 10
[04-May-2017 23:00:53 UTC] PHP Warning:  Cannot modify header information - headers already sent by (output started at /home/public/wp-content/plugins/site-icon-extended/vendor/chrisbliss18/php-ico/class-php-ico.php:10) in /home/public/wp-content/plugins/micropub/micropub.php on line 882
[04-May-2017 23:00:53 UTC] PHP Warning:  Cannot modify header information - headers already sent by (output started at /home/public/wp-content/plugins/site-icon-extended/vendor/chrisbliss18/php-ico/class-php-ico.php:10) in /home/public/wp-content/plugins/micropub/micropub.php on line 882
[04-May-2017 23:00:53 UTC] PHP Warning:  Cannot modify header information - headers already sent by (output started at /home/public/wp-content/plugins/site-icon-extended/vendor/chrisbliss18/php-ico/class-php-ico.php:10) in /home/public/wp-content/plugins/micropub/micropub.php on line 882
[04-May-2017 23:00:53 UTC] PHP Warning:  Cannot modify header information - headers already sent by (output started at /home/public/wp-content/plugins/site-icon-extended/vendor/chrisbliss18/php-ico/class-php-ico.php:10) in /home/public/wp-content/plugins/webmention/includes/class-webmention-receiver.php on line 545
[04-May-2017 23:00:53 UTC] PHP Warning:  Cannot modify header information - headers already sent by (output started at /home/public/wp-content/plugins/site-icon-extended/vendor/chrisbliss18/php-ico/class-php-ico.php:10) in /home/public/wp-content/plugins/webmention/includes/class-webmention-receiver.php on line 547
[04-May-2017 23:00:53 UTC] Micropub Data: a:1:{s:8:"micropub";s:8:"endpoint";} a:2:{s:4:"type";a:1:{i:0;s:7:"h-entry";}s:10:"properties";a:3:{s:9:"published";a:1:{i:0;s:25:"2017-05-04T18:05:58-04:00";}s:11:"syndication";a:1:{i:0;s:70:"https://www.swarmapp.com/user/1133595/checkin/590ba5c6c0f163286063f2ad";}s:7:"checkin";a:1:{i:0;a:2:{s:4:"type";a:1:{i:0;s:6:"h-card";}s:10:"properties";a:10:{s:4:"name";a:1:{i:0;s:9:"Starbucks";}s:3:"url";a:3:{i:0;s:49:"https://foursquare.com/v/4c224109fbe5c9b6a8949921";i:1;s:37:"http://www.starbucks.com/store/13579/";i:2;s:29:"https://twitter.com/starbucks";}s:3:"tel";a:1:{i:0;s:14:"(978) 475-7752";}s:8:"latitude";a:1:{i:0;d:42.656393;}s:9:"longitude";a:1:{i:0;d:-71.140289;}s:14:"street-address";a:1:{i:0;s:10:"14 Main St";}s:8:"locality";a:1:{i:0;s:7:"Andover";}s:6:"region";a:1:{i:0;s:2:"MA";}s:12:"country-name";a:1:{i:0;s:13:"United States";}s:11:"postal-code";a:1:{i:0;s:5:"01810";}}}}}}
[04-May-2017 23:00:53 UTC] Micropub HTTP headers: a:8:{s:14:"content-length";s:3:"585";s:12:"content-type";s:16:"application/json";s:6:"accept";s:3:"*/*";s:10:"connection";s:5:"close";s:4:"host";s:17:"www.darkglass.org";s:16:"x-forwarded-host";s:17:"www.darkglass.org";s:17:"x-forwarded-proto";s:5:"https";s:18:"x-forwarded-server";s:31:"edge4.phxe.nearlyfreespeech.net";}
[04-May-2017 23:00:53 UTC] PHP Notice:  Undefined index: authorization in /home/public/wp-content/plugins/micropub/micropub.php on line 893
[04-May-2017 23:00:53 UTC] PHP Notice:  Undefined index: access_token in /home/public/wp-content/plugins/micropub/micropub.php on line 158
[04-May-2017 23:00:53 UTC] PHP Warning:  Cannot modify header information - headers already sent by (output started at /home/public/wp-content/plugins/site-icon-extended/vendor/chrisbliss18/php-ico/class-php-ico.php:10) in /home/public/wp-content/plugins/micropub/micropub.php on line 882
[04-May-2017 23:01:17 UTC] PHP Deprecated:  Methods with the same name as their class will not be constructors in a future version of PHP; PHP_ICO has a deprecated constructor in /home/public/wp-content/plugins/site-icon-extended/vendor/chrisbliss18/php-ico/class-php-ico.php on line 10
[04-May-2017 23:01:19 UTC] PHP Deprecated:  Methods with the same name as their class will not be constructors in a future version of PHP; PHP_ICO has a deprecated constructor in /home/public/wp-content/plugins/site-icon-extended/vendor/chrisbliss18/php-ico/class-php-ico.php on line 10
[04-May-2017 23:01:22 UTC] PHP Deprecated:  Methods with the same name as their class will not be constructors in a future version of PHP; PHP_ICO has a deprecated constructor in /home/public/wp-content/plugins/site-icon-extended/vendor/chrisbliss18/php-ico/class-php-ico.php on line 10
[04-May-2017 23:01:23 UTC] PHP Notice:  ob_end_flush(): failed to send buffer of zlib output compression (0) in /home/public/wp-includes/functions.php on line 3720
[04-May-2017 23:01:24 UTC] PHP Deprecated:  Methods with the same name as their class will not be constructors in a future version of PHP; PHP_ICO has a deprecated constructor in /home/public/wp-content/plugins/site-icon-extended/vendor/chrisbliss18/php-ico/class-php-ico.php on line 10
[04-May-2017 23:01:32 UTC] PHP Deprecated:  Methods with the same name as their class will not be constructors in a future version of PHP; PHP_ICO has a deprecated constructor in /home/public/wp-content/plugins/site-icon-extended/vendor/chrisbliss18/php-ico/class-php-ico.php on line 10
[04-May-2017 23:01:33 UTC] PHP Notice:  Constant IS_A_PF already defined in /home/public/wp-content/plugins/pressforward/Controllers/PFtoWPTemplates.php on line 25
[04-May-2017 23:01:35 UTC] PHP Notice:  ob_end_flush(): failed to send buffer of zlib output compression (0) in /home/public/wp-includes/functions.php on line 3720

This is the request I had OwnYourSwarm try after I deactivated the other plugin:

[04-May-2017 23:01:42 UTC] Micropub Data: a:1:{s:8:"micropub";s:8:"endpoint";} a:2:{s:4:"type";a:1:{i:0;s:7:"h-entry";}s:10:"properties";a:3:{s:9:"published";a:1:{i:0;s:25:"2017-05-04T18:05:58-04:00";}s:11:"syndication";a:1:{i:0;s:70:"https://www.swarmapp.com/user/1133595/checkin/590ba5c6c0f163286063f2ad";}s:7:"checkin";a:1:{i:0;a:2:{s:4:"type";a:1:{i:0;s:6:"h-card";}s:10:"properties";a:10:{s:4:"name";a:1:{i:0;s:9:"Starbucks";}s:3:"url";a:3:{i:0;s:49:"https://foursquare.com/v/4c224109fbe5c9b6a8949921";i:1;s:37:"http://www.starbucks.com/store/13579/";i:2;s:29:"https://twitter.com/starbucks";}s:3:"tel";a:1:{i:0;s:14:"(978) 475-7752";}s:8:"latitude";a:1:{i:0;d:42.656393;}s:9:"longitude";a:1:{i:0;d:-71.140289;}s:14:"street-address";a:1:{i:0;s:10:"14 Main St";}s:8:"locality";a:1:{i:0;s:7:"Andover";}s:6:"region";a:1:{i:0;s:2:"MA";}s:12:"country-name";a:1:{i:0;s:13:"United States";}s:11:"postal-code";a:1:{i:0;s:5:"01810";}}}}}}
[04-May-2017 23:01:42 UTC] Micropub HTTP headers: a:8:{s:14:"content-length";s:3:"585";s:12:"content-type";s:16:"application/json";s:6:"accept";s:3:"*/*";s:10:"connection";s:5:"close";s:4:"host";s:17:"www.darkglass.org";s:16:"x-forwarded-host";s:17:"www.darkglass.org";s:17:"x-forwarded-proto";s:5:"https";s:18:"x-forwarded-server";s:31:"edge4.phxe.nearlyfreespeech.net";}
[04-May-2017 23:01:42 UTC] PHP Notice:  Undefined index: authorization in /home/public/wp-content/plugins/micropub/micropub.php on line 893
[04-May-2017 23:01:42 UTC] PHP Notice:  Undefined index: access_token in /home/public/wp-content/plugins/micropub/micropub.php on line 158
[04-May-2017 23:01:42 UTC] PHP Warning:  Cannot modify header information - headers already sent by (output started at /home/public/wp-content/plugins/micropub/micropub.php:893) in /home/public/wp-content/plugins/micropub/micropub.php on line 882

Let me know what you think. If it's time for me to contact the host, do you think there's any merit to the suggestion from that forum post about renaming the header:

SetEnvIf Authorization .+ MY_AUTHORIZATION=$0

Even if it wouldn't be useful for actually getting this all to work, is there a way we can test to see if the authorization token really does come through when it's renamed? It might be helpful to know when it comes to contacting them.

from wordpress-micropub.

snarfed avatar snarfed commented on May 20, 2024

thanks for doing all this extra debugging.

yup, confirmed, the header isn't coming through. the logged headers before and after deactivating that plugin were the same, and don't include Authorization:

[04-May-2017 23:00:53 UTC] Micropub HTTP headers: a:8:{s:14:"content-length";s:3:"585";s:12:"content-type";s:16:"application/json";s:6:"accept";s:3:"*/*";s:10:"connection";s:5:"close";s:4:"host";s:17:"www.darkglass.org";s:16:"x-forwarded-host";s:17:"www.darkglass.org";s:17:"x-forwarded-proto";s:5:"https";s:18:"x-forwarded-server";s:31:"edge4.phxe.nearlyfreespeech.net";}

you're welcome to try renaming it if you want! the micropub plugin won't currently find it if it's named something else, but we could definitely make that configurable in a future release.

from wordpress-micropub.

tamaracks avatar tamaracks commented on May 20, 2024

If I put the rename line in there, would it show up in the same line in debug.log if it worked?

from wordpress-micropub.

snarfed avatar snarfed commented on May 20, 2024

yup!

from wordpress-micropub.

tamaracks avatar tamaracks commented on May 20, 2024

Hmm, then it doesn't seem to come through then either. 😠 How odd.

from wordpress-micropub.

tamaracks avatar tamaracks commented on May 20, 2024

The output of the header debug line seems to have been the same for everything I've tried.

Any chance it's something about Wordpress that's causing it? Do you know for sure that others using the wordpress micropub plugin have had success with a request that includes an authorization header?

from wordpress-micropub.

snarfed avatar snarfed commented on May 20, 2024

good questions! i suspect it's getting stripped before wordpress sees it. it's definitely worked for other people, e.g. the micropub.rocks validator: https://micropub.rocks/implementation-reports/servers/27/Ouvg5VCJrclDWHUtQHXA

from wordpress-micropub.

tamaracks avatar tamaracks commented on May 20, 2024

Thanks for the help. Before I contact the host, I am trying to see if I can break it down into a simple test to check for the Authorization header without Wordpress or anything else in the mix. Can you tell me if the following should work?

I created a page called authtest.php with these contents:

<?php

    $headers = array();

    foreach($_SERVER as $key => $value) {
        if(strpos($key, 'HTTP_') === 0) {
            $headers = str_replace(' ', '-', ucwords(str_replace('_', ' ', strtolower(substr($key, 5)))));
            echo $headers." : ". $i[$headers] = $value . "<br>";
        }
    }

?>

I tried sending this curl command from my Mac:

curl -i https://www.darkglass.org/authtest.php -H "Authorization: Foobar" > debug.log

from wordpress-micropub.

snarfed avatar snarfed commented on May 20, 2024

yup! i don't really know PHP, surprisingly, but that looks good to me.

from wordpress-micropub.

tamaracks avatar tamaracks commented on May 20, 2024

from wordpress-micropub.

tamaracks avatar tamaracks commented on May 20, 2024

Well, I have an initial answer from my host. The rule in the .htaccess file puts that value into the $_SERVER variable, but not as a header, so that's why the initial PHP script I had put together wasn't returning it.

.htaccess rule I am currently using, for reference:

SetEnvIf Authorization .+ MY_AUTHORIZATION=$0

I rewrote my test script to echo everything in the $_SERVER array, and I did find the renamed variable, under $_SERVER['MY_AUTHORIZATION']. (I could name the variable something else via the rule above, of course.) If this is as much as I can get from the host, is that something that could be available to the micropub plugin if it was modified to find it?

I have replied to him to see if I can get more information about what actually happens to the header, because it still doesn't seem clear to me. He had said that the presence of an AUTH_TYPE variable in the $_SERVER array would indicate that Apache had processed the header, but as far as I can tell, that variable isn't present.

For reference, my current test script:

<?php

    foreach($_SERVER as $key => $value) {
        echo $key." : ". $value . "\n";
    }
    
    $authtype = $_SERVER['AUTH_TYPE'];
    
    if ( isset($authtype) ){
    
        echo "AUTH_TYPE: ".$_SERVER['AUTH_TYPE'].'\n';
        
    } else {
        
        echo "\nNo AUTH_TYPE found.";
        
    }
?>

My current curl request (I passed an Authorization header that I believe would look more like the Bearer token request just to be closer to the micropub request):

curl -i https://www.darkglass.org/authtest.php -H "Authorization: Bearer token cm9vdDp0MDBy" > debug.log

And the latest output from that script:

HTTP/1.1 200 OK
Date: Fri, 05 May 2017 20:37:01 GMT
Server: Apache
Content-Type: text/html; charset=UTF-8
Vary: Accept-Encoding
Transfer-Encoding: chunked

CONTEXT_PREFIX : 
DOCUMENT_ROOT : /home/public/
GATEWAY_INTERFACE : NFGI/1.0
HTTPS : on
HTTP_ACCEPT : */*
HTTP_CONNECTION : close
HTTP_HOST : www.darkglass.org
HTTP_USER_AGENT : curl/7.44.0
HTTP_X_FORWARDED_HOST : www.darkglass.org
HTTP_X_FORWARDED_PROTO : https
HTTP_X_FORWARDED_SERVER : edge4.phxe.nearlyfreespeech.net
LD_LIBRARY_PATH : /usr/lib:/usr/local/lib
MY_AUTHORIZATION : Bearer token cm9vdDp0MDBy
NFSN_REMOTE_ADDR : 108.49.152.90
NFSN_SITE_NAME : darkglass
NFSN_SITE_ROOT : /home/
PATH : /bin:/usr/bin
QUERY_STRING : 
REMOTE_ADDR : 108.49.152.90
REMOTE_PORT : 57162
REQUEST_METHOD : GET
REQUEST_SCHEME : http
REQUEST_URI : /authtest.php
SCRIPT_FILENAME : /home/public/authtest.php
SCRIPT_NAME : /authtest.php
SERVER_ADDR : 172.17.1.55
SERVER_ADMIN : nobody
SERVER_NAME : www.darkglass.org
SERVER_PORT : 80
SERVER_PROTOCOL : HTTP/1.1
TMPDIR : /home/tmp/
UNIQUE_ID : WQzibawRyAgAAPyik6MAAACx
PHP_SELF : /authtest.php
REQUEST_TIME_FLOAT : 1494016621.7663
REQUEST_TIME : 1494016621
argv : Array
argc : 0

No AUTH_TYPE found.

from wordpress-micropub.

tamaracks avatar tamaracks commented on May 20, 2024

Well, I was bored, so I poked at it a bit. I got it to be able to recognize the token by giving my renamed server variable a four-letter plus underscore prefix and modifying line 911 of micropub.php. I chose MENV_ (so MENV_AUTHORIZATION) and changed line 911 to

if ( substr( $name, 0, 5 ) == 'HTTP_' OR substr( $name, 0, 5 ) == 'MENV_' ) {

so that it would pick up my variable in addition to the HTTP_ variables. I have no idea if this is a good way to solve it, but it works, for some value of works.

Unfortunately, the plugin endpoint doesn't seem to know what to do with most of the data that OwnYourSwarm throws at it. Most of it doesn't get imported, like I think anything in the "checkin" section of the h-entry object, which is a bunch of the location stuff. Also, it fails to post if no comment was added because then it's missing content, title, and excerpt fields. I am not really sure where to start to try to solve this part. I don't sufficiently understand how micropub.php intakes the data, what kind of data it expects, and what it does with it to put it into WP.

from wordpress-micropub.

aaronpk avatar aaronpk commented on May 20, 2024

So it sounds like the host is specifically blacklisting the Authorization header which is why you're able to use it as a different name. Your workaround is clever, and it's not a terrible idea, but I'm not sure how we could generalize that as a solution in the plugin.

As for the other issues, I think I want to provide a better fallback behavior for Micropub endpoints that don't support the checkin object. Can you open a new issue on OwnYourSwarm to request better fallback behavior? I'm thinking that it could at least have an option to post a text summary of the checkin instead of or in addition to the checkin object.

from wordpress-micropub.

tamaracks avatar tamaracks commented on May 20, 2024

from wordpress-micropub.

snarfed avatar snarfed commented on May 20, 2024

thanks again for the detailed sleuthing, all!

re the checkin object, @aaronpk's idea for a fallback is good, since it's not yet part of either the micropub or microformats2 spec, but OwnYourSwarm is a valuable service, so I'm happy to add support for it anyway. I'll track that in this issue.

from wordpress-micropub.

snarfed avatar snarfed commented on May 20, 2024

hey @tamaracks, if you're up for switching your plugin to the code at github head, it now handles OwnYourSwarm's checkin objects and auto-generates content. feel free to try it! otherwise i'll test it and cut a release soon.

from wordpress-micropub.

tamaracks avatar tamaracks commented on May 20, 2024

That was quick! And it seems to work! I copied the raw code for micropub.php and pasted it into micropub.php on my server (and added back my little modification to catch the authorization), and had OwnYourSwarm resend the last checkin. OYS got a successful response and I got a post in WP that says "Checked into Starbucks." With custom fields filled in for geo_address, geo_longitude, and geo_latitude.

Would it make sense to add a link to the checkin itself in there somewhere? I know it's stored in the syndication links, but I would think that would be hard to display on the final page because even if it's accessible to the theme, other links may get added later.

And this also leads me to something else I've been thinking of for the micropub plugin. Is it possible to add some kind of default slug for posts with no title? I really dislike having the Wordpress post ID in the permalink, because it seems like a particularly meaningless piece of data. Even something date-based, like '%Y-%m-%d-%H%M' as the slug would be preferable (bonus if it could be user-configurable).

Similarly, it seems like the Post Kind is set correctly, but it would be cool if the WP post format could also be set to something other than standard for a title-less post, like aside. I am pretty sure that my theme (SenPress, child of SemPress) is basing the template on post format, and aside prevents an ugly title link based on post ID. This isn't as vital as above, because it's relatively easy to change later, unlike the permalink, which can get shared right away by syndication, but it would be handy.

I can open new issues for any of these if you'd prefer.

from wordpress-micropub.

snarfed avatar snarfed commented on May 20, 2024

hey, thanks for testing!

i can definitely link to the checkin, but the OYS docs say the link isn't public, it's only visible to your friends on foursquare - https://ownyourswarm.p3k.io/docs#checkins - which is why i omitted it for now. let me know what you think.

as for slug, i think you can actually configure the default on your own wordpress instance...? assuming so, i'd probably defer to that instead of setting the slug explicitly in the plugin.

as for post kinds, i'm actually not too familiar with them, and they're part of a separate plugin, so i'm just going to cc @dshanske and step back...

from wordpress-micropub.

tamaracks avatar tamaracks commented on May 20, 2024

Ah ha, that's probably a good point about the checkin link.

I don't think you can configure how the slug works. At least not that I can see or find reference to. You can set a permalink style in WP settings that wouldn't use the slug (called %postname% in WP terminology) or post title, but I don't want to change the permalink style. I like using the title as part of the permalink. It's only a problem when posting something that isn't given a title. Which, for indieweb happens with things like notes. But Wordpress, if you put a title for the post, it auto-generates a slug based on the title. And if you don't put a title, it sets the post ID as the slug. Which you can change in the add/edit post screen, but if syndication is set up, then by the time you go back and change it, the initial permalink is already out there in the world.

And I didn't mean setting the post kind, I meant setting the post format, which is part of Wordpress itself. (I do wish something would tie post kind and post format together, but that's definitely outside the scope of this discussion.) Although looking closer, I guess that the posts coming in the micropub endpoint may just be using the setting that the Post Kinds plugin has for the default kind on new posts. But in any case, I mean the Post Format.

from wordpress-micropub.

snarfed avatar snarfed commented on May 20, 2024

thanks for the clarifications! and sorry, should have read more carefully originally. :P

i get your point about posts without title using post id for slug. it's a bit orthogonal, though - it affects all posts, not just ones created via micropub, and it's somewhat personal preference - so it may be more appropriate for a separate plugin?

as for post format, makes sense. any idea how that should work? ie would you pass in post format as a custom mf2 property inside the micropub request? or just always use a specific format for title-less posts?

from wordpress-micropub.

tamaracks avatar tamaracks commented on May 20, 2024

Hey, hey, I got my plugin to work! In a very rudimentary way, anyway. So far, it seems that it runs every time a post is saved, not just the first time. It should only matter if the title is added or removed. Or if I check for the post name first, then it won't run at all when creating a title-less post in the Wordpress post editor, because if you don't put a title there, Wordpress puts 'auto-draft' in the slug field.

Anyway, it works well enough to take care of my need here, as far as the post name/slug goes.

Presumably, I could write something similar for controlling post format, but I haven't been able to discover where that data is stored in the post array.

from wordpress-micropub.

tamaracks avatar tamaracks commented on May 20, 2024

One other thing that occurred to me while testing. If a Swarm checkin has an accompanying text status update entered by the user, then the line you added about checking in at the place with a link isn't included.

I can see this being kind of tricky, because how far do you go in adding content? You could add the "Checked into..." line to the end of the post content that came through. It might be that not everyone would want that. But without it, there's no way to get that link later or add it oneself.

from wordpress-micropub.

snarfed avatar snarfed commented on May 20, 2024

congrats on getting your plugin working!

when micropub creates or edits a post, it stores the full original mf2 in post meta, so you can get the venue and checkin link (etc) later in code. regardless, i can definitely still include the Checked into... line when there's content and also a checkin property. i'll do that.

from wordpress-micropub.

tamaracks avatar tamaracks commented on May 20, 2024

I was also able to cobble together a rather hacky plugin to set category and format automatically on these posts, based on finding the text 'Checked into <a' in the content. So I think I've got that part covered as well, if you don't think it belongs in micropub.php. Maybe some day I can figure out a way to make it more generalized and flexible, but it serves for now.

Thus, I would appreciate the change that adds the checked into line when there's content. 😉 Maybe there's a more robust way to identify those posts, but I haven't thought of it yet.

from wordpress-micropub.

chrisaldrich avatar chrisaldrich commented on May 20, 2024

@tamaracks If you push the code you have for setting the format to @dshanske I suspect he could roll it into Post Kinds (which also automatically sets the Post Format) so that it's covered for everyone else who may have this issue.

from wordpress-micropub.

tamaracks avatar tamaracks commented on May 20, 2024

@chrisaldrich It's really just a basic check that the post category is uncategorized (ID 1, technically), and that the content contains 'Checked into <a', which matches the default content that @snarfed added for OwnYourSwarm posts. I am not sure it's worth sharing at this stage. 😀

Understanding Post Kinds better is on my list, because I am not sure that I have seen it do anything automatically yet, so I don't really know what it is supposed to do. I don't know if I am missing something or what.

from wordpress-micropub.

chrisaldrich avatar chrisaldrich commented on May 20, 2024

@tamaracks There's no need to explicitly set a Post Format in WordPress as it will automatically be set based on the Post Kind setting in Post Kinds on initial publish. (You can also tweak them by hand if necessary, so for example when using the note kind it automatically sets the Post Format to aside, but I prefer to use status, so I replaced aside with status just under 'note' => array( in the code here: https://github.com/dshanske/indieweb-post-kinds/blob/master/includes/class-kind-taxonomy.php

I also think @dshanske fixed the proper kind settings on micropub in the latest development branch of post kinds as well. dshanske/indieweb-post-kinds#87 (Hopefully this should take care of checkins as well.)

from wordpress-micropub.

tamaracks avatar tamaracks commented on May 20, 2024

@chrisaldrich I have not found that to be true at all for me. I routinely get posts with a kind of Note and a format of Standard. I guess I should check in over on that project to see what's up.

from wordpress-micropub.

snarfed avatar snarfed commented on May 20, 2024

@tamaracks i remembered why the micropub plugin omits the auto-generated Checked into ... if there's content. it omits it if you also have the Post Kinds plugin or an mf2-aware theme installed, since those want to handle rendering mf2 properties themselves.

@dshanske, do you have any plans to support OwnYourSwarm's checkin mf2 property in Post Kinds and render the checkin yourself? if not, i'm happy to do it in this plugin.

from wordpress-micropub.

snarfed avatar snarfed commented on May 20, 2024

@tamaracks the code at HEAD now includes the Checked into... text even with the Post Kinds plugin. feel free to try it!

from wordpress-micropub.

dshanske avatar dshanske commented on May 20, 2024

I have plans to build check-ins into Post Kinds. They are a future plan as of now

from wordpress-micropub.

tamaracks avatar tamaracks commented on May 20, 2024

@snarfed Thanks for the update! I missed it earlier. Just pasted the new code into the PHP file. Haven't tested it yet, I'll see what happens with the next checkin. 😄

from wordpress-micropub.

snarfed avatar snarfed commented on May 20, 2024

tentatively closing. feel free to reopen!

from wordpress-micropub.

tamaracks avatar tamaracks commented on May 20, 2024

Sorry, I meant to update. I have been getting the checked into line, thanks!

I still have the original issue with the authentication header, although I can understand it might be a very narrow problem that is hard to have a good solution on this end. I am certainly capable of continuing to make the change I mentioned above when I update the plugin.

I still hold out hope that it might be a bug, but I haven't heard back from my host one way or the other.

from wordpress-micropub.

snarfed avatar snarfed commented on May 20, 2024

thanks again for the detailed debugging! and i'm totally open to merging a PR with your workaround so you don't have to maintain it separately. maybe with the MENV_ prefix configurable in wp-config.php or something similar. feel free to send one!

from wordpress-micropub.

Related Issues (20)

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.