Skip to content

Commit

Permalink
added mp-type=checkin to micropub publish request as of idno/known#12…
Browse files Browse the repository at this point in the history
  • Loading branch information
diplix committed Feb 16, 2016
1 parent 6b51c95 commit b383f52
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/helpers.php
Expand Up @@ -100,6 +100,8 @@ function micropub_post($endpoint, $access_token, $params, $photo_filename=false,
'access_token' => $access_token
);

if(k($params, 'mp-type'))
$postfields['mp-type'] = $params['mp-type'];
if(k($params, 'content'))
$postfields['content'] = $params['content'];
if(k($params, 'category'))
Expand Down Expand Up @@ -149,6 +151,7 @@ function micropub_post($endpoint, $access_token, $params, $photo_filename=false,
// Given an Foursquare photo object, return an h-entry array with all the necessary keys
function h_entry_from_checkin(&$user, &$photo) {
$entry = array(
'mp-type' => null,
'published' => null,
'location' => null,
'place_name' => null,
Expand All @@ -175,13 +178,15 @@ function h_entry_from_checkin(&$user, &$photo) {
if($photo->venue->name)
$entry['place_name'] = $photo->venue->name;
if($photo->venue->id)
$entry['place_url'] = 'https://foursquare.com/venue/'.$photo->venue->id;
$entry['place_url'] = 'https://foursquare.com/venue/'.$photo->venue->id."?ref=".Config::$fsqClientID;

// Add the regular tags to the category array
/*
if($photo->tags)
$entry['category'] = array_merge($entry['category'], $photo->tags);
*/
$entry['mp-type'] = "checkin";

$entry['category'][] = "checkin";
$entry['category'][] = "foursquare";
$entry['category'][] = "4sq"; // city, street, plz:plz
Expand Down

10 comments on commit b383f52

@danito
Copy link

@danito danito commented on b383f52 Feb 17, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,
did you already update ownyourcheckin.wirres.net with this?
My Endpoint doesn't get it and it's not listed in the fields listed in /fsq.

@diplix
Copy link
Owner Author

@diplix diplix commented on b383f52 Feb 17, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, of course. however your server returns a 500 error:

Sending checkin to micropub endpoint: https://nxd4n.nixekinder.be/micropub/endpoint
Array
(
    [mp-type] => checkin
    [published] => 2016-02-17T15:04:41+01:00
    [location] => geo:50.838521967589,4.3760776519775
    [place_name] => European Parliament - Paul-Henri Spaak Building
    [place_url] => https://foursquare.com/venue/554e1485498eb7864c72636b?ref=YOFY2SHCUPCRRJUBFNI2D1SU3IKOFBHOGSX3ZN5CDEARGODM
    [category] => Array
        (
            [0] => Bâtiment gouvernemental
            [1] => checkin
            [2] => foursquare
        )

    [content] => 
    [syndication] => https://foursquare.com/forward/checkin/56c47df9498e6c282c01c3e5
)

Array
(
    [response] => HTTP/1.1 500 Internal Server Error

Date: Wed, 17 Feb 2016 14:05:13 GMT

Server: Apache/2.2.15 (CentOS)

P3P: CP="CAO PSA OUR"

Expires: Thu, 19 Nov 1981 08:52:00 GMT

Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0

Pragma: no-cache

Link: <https://nxd4n.nixekinder.be/micropub/endpoint>; rel="micropub"

X-Powered-By: https://withknown.com

X-Clacks-Overhead: GNU Terry Pratchett

Set-Cookie: known=xxx; expires=Wed, 24-Feb-2016 14:05:14 GMT; Max-Age=604800; path=/; secure; HttpOnly

Connection: close

Transfer-Encoding: chunked

Content-Type: text/html; charset=UTF-8



<h1>Oh no! Known experienced a problem!</h1><p>Known experienced a problem with this page and couldn't continue. The technical details are as follows:</p><pre>Fatal Error: /var/www/virtual/nxd4n/html/IdnoPlugins/IndiePub/Pages/MicroPub/Endpoint.php:87 - "Class 'IdnoPlugins\IndiePub\Pages\MicroPub\Idno\Core\Idno' not found", on page nxd4n.nixekinder.be/micropub/endpoint</pre><p>If you like, you can <a href="mailto:hello@withknown.com?subject=Fatal%20error%20in%20Known%20install%20at%20nxd4n.nixekinder.be%2Fmicropub%2Fendpoint&body=Fatal%20Error%3A%20%2Fvar%2Fwww%2Fvirtual%2Fnxd4n%2Fhtml%2FIdnoPlugins%2FIndiePub%2FPages%2FMicroPub%2FEndpoint.php%3A87%20-%20%22Class%20%27IdnoPlugins%5CIndiePub%5CPages%5CMicroPub%5CIdno%5CCore%5CIdno%27%20not%20found%22%2C%20on%20page%20nxd4n.nixekinder.be%2Fmicropub%2Fendpoint">email us for more information</a>.
    [error] => 

@danito
Copy link

@danito danito commented on b383f52 Feb 17, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

corrected.
But still
$mp_type = $this->getInput('mp-type');
is empty... the other variables are ok

@danito
Copy link

@danito danito commented on b383f52 Feb 17, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's the $_REQUEST I get on my Endpoint :

Array
 (
     [/micropub/endpoint] => 
     [h] => entry
     [access_token] => 123abc123abc123abctoolateiknow
     [content] => Office with a view
     [category] => Array
         (
             [0] => Park
             [1] => checkin
             [2] => foursquare
         )
     [place_name] => Parc L\xc3\xa9opoldpark
     [location] => geo:50.838603271686,4.3791675567627
     [published] => 2016-02-17T15:49:58+01:00
     [syndication] => https://foursquare.com/forward/checkin/56c48896498e3b6ff1c4d823
 )

bizarre
Even [photo] is missing

@diplix
Copy link
Owner Author

@diplix diplix commented on b383f52 Feb 17, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

your know is still producing a 500 error.

Sending checkin to micropub endpoint: https://nxd4n.n
Array
(
    [mp-type] => checkin
    [published] => 2016-02-17T15:49:58+01:00
    [location] => geo:50.838603271686,4.3791675567627
    [place_name] => Parc Léopoldpark
    [place_url] => https://foursquare.com/venue/4c07d
    [category] => Array
        (
            [0] => Parc
            [1] => checkin
            [2] => foursquare
        )

    [content] => Office with a view
    [syndication] => https://foursquare.com/forward/c
)

Array
(
    [response] => HTTP/1.1 500 Internal Server Error

Date: Wed, 17 Feb 2016 14:50:33 GMT

and this is what my mp-endpoint receives:

array(9) {
["h"]=>
string(5) "entry"
["access_token"]=>
string(332) "xxx"
["mp-type"]=>
string(7) "checkin"
["category"]=>
array(3) {
[0]=>
string(6) "Office"
[1]=>
string(7) "checkin"
[2]=>
string(10) "foursquare"
}
["place_name"]=>
string(8) "EsPresto"
["place_url"]=>
string(106) "https://foursquare.com/venue/4b0a4a20f964a520052323e3?ref=YOFY2SHCUPCRRJUBFNI2D1SU3IKOFBHOGSX3ZN5CDEARGODM"
["location"]=>
string(34) "geo:52.515498799716,13.40467755187"
["published"]=>
string(25) "2016-02-17T10:33:17+01:00"
["syndication"]=>
string(63) "https://foursquare.com/forward/checkin/56c43e5d498e5addebff2410"
}

@danito
Copy link

@danito danito commented on b383f52 Feb 17, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could it be that the "TEST" button isn't sending the mp-type?

<script>
$(function(){
  $("#btn_test_post").click(function(){

    var categories = [];
    $(".photo_category").each(function(){
      categories.push($(this).val());
    });

    $.post("/micropub/test", {
      content: $("#photo_content").val(),
      url: $("#photo_url").val(),
      published: $("#photo_published").val(),
      location: $("#photo_location").val(),
      place_name: $("#photo_place_name").val(),
      category: categories,
      syndication: $("#photo_syndication").val()
    }, function(data){
      var response = JSON.parse(data);
      if(response.location != false) {
        $("#test_success").removeClass('hidden');
        $("#test_error").addClass('hidden');
      } else {
        $("#test_success").addClass('hidden');
        $("#test_error").removeClass('hidden');
      }
      $("#test_response").html(response.response);
    })
  });

  $("#micropub_array").click(function(){
    $.post("/prefs/array", {
      upgrade: "yes"
    }, function(data) {
      $("#array_notice").hide();
      window.location = window.location;
    });
  });
});
</script>

As I didn't wait for your script to run in background, I was triggering it from the website...

@diplix
Copy link
Owner Author

@diplix diplix commented on b383f52 Feb 17, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, you’re right. the test-button does not send that yet. just as it doesn’t send video in ownyourgram.

@danito
Copy link

@danito danito commented on b383f52 Feb 17, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That explains the missing fields... and why endpoint didn't recognize it.
For my latest checkin https://nxd4n.nixekinder.be/2016/checked-into-parlement-europ%c3%a9en-european-parliament-1 I got the mp-type 👍

@diplix
Copy link
Owner Author

@diplix diplix commented on b383f52 Feb 17, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@diplix
Copy link
Owner Author

@diplix diplix commented on b383f52 Feb 17, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎱

Please sign in to comment.