Skip to content

Instantly share code, notes, and snippets.

@localdisk
Created May 13, 2014 02:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save localdisk/f4ffe0040a328522455d to your computer and use it in GitHub Desktop.
Save localdisk/f4ffe0040a328522455d to your computer and use it in GitHub Desktop.
Backlog API
<?php
namespace Backlog;
use GuzzleHttp\Client;
class XmlRpcSample
{
protected $url;
protected $user;
protected $password;
public function __construct($url, $user, $password)
{
$this->url = $url;
$this->user = $user;
$this->password = $password;
}
public function send($method, $params = [])
{
$body = xmlrpc_encode_request($method, $params);
$response = (new Client)->post($this->url, [
'body' => $body,
'auth' => [$this->user, $this->password]
]);
return $response->xml();
}
}
require_once '../vendor/autoload.php';
$api = new \Backlog\XmlRpcSample('https://demo.backlog.jp/XML-RPC', 'demo', 'demo');
$res = $api->send('getProjects');
var_dump($res);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment