11 public function __construct($host)
16 public function run($url)
18 $url = Validator::url($url, 'url');
23 $body = http_build_query(
30 $req = new \HTTP_Request2($this->host->endpoints->micropub, 'POST');
31 if (version_compare(PHP_VERSION, '5.6.0', '<')) {
32 //correct ssl validation on php 5.5 is a pain, so disable
33 $req->setConfig('ssl_verify_host', false);
34 $req->setConfig('ssl_verify_peer', false);
36 $req->setHeader('Content-type', 'application/x-www-form-urlencoded');
37 $req->setHeader('Authorization', 'Bearer ' . $this->host->token);
40 if (intval($res->getStatus() / 100) != 2) {
42 'Server returned an error status code ' . $res->getStatus()
44 Log::err($res->getBody());
47 $postUrl = $res->getHeader('Location');
48 echo "Like created at server\n";