- $req = new \HTTP_Request2($this->host->endpoints->micropub, 'POST');
- if (version_compare(PHP_VERSION, '5.6.0', '<')) {
- //correct ssl validation on php 5.5 is a pain, so disable
- $req->setConfig('ssl_verify_host', false);
- $req->setConfig('ssl_verify_peer', false);
- }
- $req->setHeader('Content-type', 'application/x-www-form-urlencoded');
- $req->setHeader('Authorization', 'Bearer ' . $this->host->token);
- $req->setBody($body);
- $res = $req->send();
- if (intval($res->getStatus() / 100) != 2) {
- Log::err(
- 'Server returned an error status code ' . $res->getStatus()
- );
+ $req = new Request($this->cfg->host, $this->cfg);
+ $res = $req->send($body);
+ $postUrl = $res->getHeader('Location');
+ if ($postUrl === null) {
+ Log::err('Error: Server sent no "Location" header and said:');