{"id":4929,"date":"2017-05-08T19:21:15","date_gmt":"2017-05-08T19:21:15","guid":{"rendered":"http:\/\/johnjohnston.info\/blog\/?p=4929"},"modified":"2017-05-08T19:21:37","modified_gmt":"2017-05-08T19:21:37","slug":"microblogging-adventures-pt-2-alfred-post-to-wordpress-for-micro-blog","status":"publish","type":"post","link":"https:\/\/johnjohnston.info\/blog\/microblogging-adventures-pt-2-alfred-post-to-wordpress-for-micro-blog\/","title":{"rendered":"Microblogging adventures pt 2: Alfred post to WordPress for micro.blog"},"content":{"rendered":"<p>I&#8217;ve been beta testing micro.blog. There is a new page here for status type posts, these get sent to <a href=\"http:\/\/micro.blog\/johnjohnston\">micro.blog\/johnjohnston<\/a> and to twitter.<\/p>\n<p>This has renewed my interest in finding different ways to post to the blog especially for short posts that would have previously gone straight to twitter.<\/p>\n<p><!--more--><\/p>\n<p>On iOS there is the nice micro.blog app, editorial or drafts and workflow. On my mac I&#8217;ve used AppleScript to post to blogs before, but needed to figure out how to add a category for the micro blog. I also wanted to not have a title, use the format of status and the note kind. The categories and kinds were the tricky bit, they need to be in a <em>strut within a strut\u00a0<\/em>in the datas sent to the xml-rpc end point (I am a wee bit wobbly on the vocabulary here).<\/p>\n<p>The following script does the trick. It is fairly limited as I hard code various things into it:<\/p>\n<ul>\n<li>user name<\/li>\n<li>password &#8211; this is probably not the greatest idea.<\/li>\n<li>the category micro<\/li>\n<li>the post format and kind<\/li>\n<li>an empty title<\/li>\n<\/ul>\n<p>It should be obvious how to change most of these things and make the script fit other needs or\u00a0to generalise it.<\/p>\n<p>I also wanted to be able to post from any application, so this script is for Alfred. In a workflow this is triggered by a hotkey which sends the currently selected text to the script. The script passes on the returned info, the post id, to a notification.<\/p>\n<p>So to post a quick stratus method I select some text \u00a0hit cmd-alt-control-m and that test gets posted here.<\/p>\n<style>.gist table { margin-bottom: 0; }<\/style>\n<div style=\"tab-size: 8\" id=\"gist47475712\" class=\"gist\">\n<div class=\"gist-file\" translate=\"no\" data-color-mode=\"light\" data-light-theme=\"light\">\n<div class=\"gist-data\">\n<div class=\"js-gist-file-update-container js-task-list-container\">\n<div id=\"file-postto-micro-blog-scpt\" class=\"file my-2\">\n<div itemprop=\"text\"\n      class=\"Box-body p-0 blob-wrapper data type-applescript  \"\n      style=\"overflow: auto\" tabindex=\"0\" role=\"region\"\n      aria-label=\"postto-micro.blog.scpt content, created by troutcolor on 06:43PM on May 08, 2017.\"\n    ><\/p>\n<div class=\"js-check-hidden-unicode js-blob-code-container blob-code-content\">\n<p>  <template class=\"js-file-alert-template\"><\/p>\n<div data-view-component=\"true\" class=\"flash flash-warn flash-full d-flex flex-items-center\">\n  <svg aria-hidden=\"true\" height=\"16\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" data-view-component=\"true\" class=\"octicon octicon-alert\">\n    <path d=\"M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z\"><\/path>\n<\/svg><br \/>\n    <span><br \/>\n      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.<br \/>\n      <a class=\"Link--inTextBlock\" href=\"https:\/\/github.co\/hiddenchars\" target=\"_blank\">Learn more about bidirectional Unicode characters<\/a><br \/>\n    <\/span><\/p>\n<div data-view-component=\"true\" class=\"flash-action\">        <a href=\"{{ revealButtonHref }}\" data-view-component=\"true\" class=\"btn-sm btn\">    Show hidden characters<br \/>\n<\/a>\n<\/div>\n<\/div>\n<p><\/template><br \/>\n<template class=\"js-line-alert-template\"><br \/>\n  <span aria-label=\"This line has hidden Unicode characters\" data-view-component=\"true\" class=\"line-alert tooltipped tooltipped-e\"><br \/>\n    <svg aria-hidden=\"true\" height=\"16\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" data-view-component=\"true\" class=\"octicon octicon-alert\">\n    <path d=\"M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z\"><\/path>\n<\/svg><br \/>\n<\/span><\/template><\/p>\n<table data-hpc class=\"highlight tab-size js-file-line-container\" data-tab-size=\"4\" data-paste-markdown-skip data-tagsearch-path=\"postto-micro.blog.scpt\">\n<tr>\n<td id=\"file-postto-micro-blog-scpt-L1\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"1\"><\/td>\n<td id=\"file-postto-micro-blog-scpt-LC1\" class=\"blob-code blob-code-inner js-file-line\">on alfred_script(q)<\/td>\n<\/tr>\n<tr>\n<td id=\"file-postto-micro-blog-scpt-L2\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"2\"><\/td>\n<td id=\"file-postto-micro-blog-scpt-LC2\" class=\"blob-code blob-code-inner js-file-line\">\tset myBlogUsername to &quot;USERNAME&quot;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-postto-micro-blog-scpt-L3\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"3\"><\/td>\n<td id=\"file-postto-micro-blog-scpt-LC3\" class=\"blob-code blob-code-inner js-file-line\">\tset myBlogPass to &quot;PASSWORD&quot;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-postto-micro-blog-scpt-L4\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"4\"><\/td>\n<td id=\"file-postto-micro-blog-scpt-LC4\" class=\"blob-code blob-code-inner js-file-line\">\tset cat to {category:{&quot;Micro&quot;}, kind:{&quot;note&quot;}}<\/td>\n<\/tr>\n<tr>\n<td id=\"file-postto-micro-blog-scpt-L5\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"5\"><\/td>\n<td id=\"file-postto-micro-blog-scpt-LC5\" class=\"blob-code blob-code-inner js-file-line\">\tset poststrut to {post_type:&quot;post&quot;, post_status:&quot;publish&quot;, post_format:&quot;status&quot;, post_title:&quot;&quot;, post_content:q, terms_names:cat, comment_status:&quot;open&quot;}\t<\/td>\n<\/tr>\n<tr>\n<td id=\"file-postto-micro-blog-scpt-L6\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"6\"><\/td>\n<td id=\"file-postto-micro-blog-scpt-LC6\" class=\"blob-code blob-code-inner js-file-line\">\ttell application &quot;http:\/\/example.com\/xmlrpc.php&quot;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-postto-micro-blog-scpt-L7\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"7\"><\/td>\n<td id=\"file-postto-micro-blog-scpt-LC7\" class=\"blob-code blob-code-inner js-file-line\">\t\tset myPosts to call xmlrpc {method name:&quot;wp.newPost&quot;, parameters:{&quot;1&quot;, myBlogUsername, myBlogPass, poststrut}}<\/td>\n<\/tr>\n<tr>\n<td id=\"file-postto-micro-blog-scpt-L8\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"8\"><\/td>\n<td id=\"file-postto-micro-blog-scpt-LC8\" class=\"blob-code blob-code-inner js-file-line\">\t\treturn  myPosts\t\t\t\t<\/td>\n<\/tr>\n<tr>\n<td id=\"file-postto-micro-blog-scpt-L9\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"9\"><\/td>\n<td id=\"file-postto-micro-blog-scpt-LC9\" class=\"blob-code blob-code-inner js-file-line\">\tend tell<\/td>\n<\/tr>\n<tr>\n<td id=\"file-postto-micro-blog-scpt-L10\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"10\"><\/td>\n<td id=\"file-postto-micro-blog-scpt-LC10\" class=\"blob-code blob-code-inner js-file-line\">end alfred_script<\/td>\n<\/tr>\n<\/table>\n<\/div><\/div>\n<\/p><\/div>\n<\/div><\/div>\n<div class=\"gist-meta\">\n        <a href=\"https:\/\/gist.github.com\/troutcolor\/51cf0f81308210886b97c5fe2dafc6d0\/raw\/5790a55547ca7f0042d21eeb2c11eb2bc569b331\/postto-micro.blog.scpt\" style=\"float:right\" class=\"Link--inTextBlock\">view raw<\/a><br \/>\n        <a href=\"https:\/\/gist.github.com\/troutcolor\/51cf0f81308210886b97c5fe2dafc6d0#file-postto-micro-blog-scpt\" class=\"Link--inTextBlock\"><br \/>\n          postto-micro.blog.scpt<br \/>\n        <\/a><br \/>\n        hosted with &#10084; by <a class=\"Link--inTextBlock\" href=\"https:\/\/github.com\">GitHub<\/a>\n      <\/div>\n<\/p><\/div>\n<\/div>\n<p>Of interest to micro.blogista is the <code>comment_status:\"open\"<\/code> bit. I am thinking of all sorts of ways to extend this, perhaps for use in FastScripts to grab the selecting and link from Safari. I&#8217;d have probably used FastScripts for this, but I can&#8217;t figure out how to get the selection from any text in plain AppleScript, I needed Alfred for that.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve been beta testing micro.blog. There is a new page here for status type posts, these get sent to micro.blog\/johnjohnston and to twitter. This has renewed my interest in finding different ways to post to the blog especially for short posts that would have previously gone straight to twitter.<\/p>\n","protected":false},"author":1,"featured_media":4932,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"mf2_syndication":[],"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"webmentions_disabled_pings":false,"webmentions_disabled":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[660,6],"tags":[665,93,42,664,44],"post_format":[],"class_list":{"0":"post-4929","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-micro","8":"category-wwwd","9":"tag-alfred","10":"tag-applescript","11":"tag-automation","12":"tag-micro-blog","13":"tag-scripting","14":"kind-note","16":"h-entry","17":"hentry"},"better_featured_image":{"id":4932,"alt_text":"","caption":"","description":"","media_type":"image","media_details":{"width":800,"height":273,"file":"2017\/05\/alfred-mico.blog_.jpg","sizes":{"thumbnail":{"file":"alfred-mico.blog_-150x150.jpg","width":150,"height":150,"mime-type":"image\/jpeg","source_url":"https:\/\/johnjohnston.info\/blog\/wp-content\/uploads\/2017\/05\/alfred-mico.blog_-150x150.jpg"},"medium":{"file":"alfred-mico.blog_-620x212.jpg","width":620,"height":212,"mime-type":"image\/jpeg","source_url":"https:\/\/johnjohnston.info\/blog\/wp-content\/uploads\/2017\/05\/alfred-mico.blog_-620x212.jpg"},"medium_large":{"file":"alfred-mico.blog_-768x262.jpg","width":768,"height":262,"mime-type":"image\/jpeg","source_url":"https:\/\/johnjohnston.info\/blog\/wp-content\/uploads\/2017\/05\/alfred-mico.blog_-768x262.jpg"},"post-thumbnail":{"file":"alfred-mico.blog_-668x228.jpg","width":668,"height":228,"mime-type":"image\/jpeg","source_url":"https:\/\/johnjohnston.info\/blog\/wp-content\/uploads\/2017\/05\/alfred-mico.blog_-668x228.jpg"},"sempress-image-post":{"file":"alfred-mico.blog_-668x228.jpg","width":668,"height":228,"mime-type":"image\/jpeg","source_url":"https:\/\/johnjohnston.info\/blog\/wp-content\/uploads\/2017\/05\/alfred-mico.blog_-668x228.jpg"},"rpwe-thumbnail":{"file":"alfred-mico.blog_-45x45.jpg","width":45,"height":45,"mime-type":"image\/jpeg","source_url":"https:\/\/johnjohnston.info\/blog\/wp-content\/uploads\/2017\/05\/alfred-mico.blog_-45x45.jpg"},"jetpack-portfolio-admin-thumb":{"file":"alfred-mico.blog_-50x50.jpg","width":50,"height":50,"mime-type":"image\/jpeg","source_url":"https:\/\/johnjohnston.info\/blog\/wp-content\/uploads\/2017\/05\/alfred-mico.blog_-50x50.jpg"}},"image_meta":{"aperture":"0","credit":"","camera":"","caption":"","created_timestamp":"0","copyright":"","focal_length":"0","iso":"0","shutter_speed":"0","title":"","orientation":"0","keywords":[]}},"post":4929,"source_url":"https:\/\/johnjohnston.info\/blog\/wp-content\/uploads\/2017\/05\/alfred-mico.blog_.jpg"},"jetpack_featured_media_url":"https:\/\/johnjohnston.info\/blog\/wp-content\/uploads\/2017\/05\/alfred-mico.blog_.jpg","jetpack_shortlink":"https:\/\/wp.me\/p57zFQ-1hv","jetpack_likes_enabled":false,"jetpack_sharing_enabled":true,"kind":false,"_links":{"self":[{"href":"https:\/\/johnjohnston.info\/blog\/wp-json\/wp\/v2\/posts\/4929","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/johnjohnston.info\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/johnjohnston.info\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/johnjohnston.info\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/johnjohnston.info\/blog\/wp-json\/wp\/v2\/comments?post=4929"}],"version-history":[{"count":3,"href":"https:\/\/johnjohnston.info\/blog\/wp-json\/wp\/v2\/posts\/4929\/revisions"}],"predecessor-version":[{"id":4935,"href":"https:\/\/johnjohnston.info\/blog\/wp-json\/wp\/v2\/posts\/4929\/revisions\/4935"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/johnjohnston.info\/blog\/wp-json\/wp\/v2\/media\/4932"}],"wp:attachment":[{"href":"https:\/\/johnjohnston.info\/blog\/wp-json\/wp\/v2\/media?parent=4929"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/johnjohnston.info\/blog\/wp-json\/wp\/v2\/categories?post=4929"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/johnjohnston.info\/blog\/wp-json\/wp\/v2\/tags?post=4929"},{"taxonomy":"post_format","embeddable":true,"href":"https:\/\/johnjohnston.info\/blog\/wp-json\/wp\/v2\/post_format?post=4929"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}