Skip to content

Instantly share code, notes, and snippets.

@wokamoto
Last active August 29, 2015 13:56
Show Gist options
  • Save wokamoto/8838684 to your computer and use it in GitHub Desktop.
Save wokamoto/8838684 to your computer and use it in GitHub Desktop.
[WordPress][Backlog API] WordPress から xmlrpc クライアントをしようして、backlog API を叩く
<?php
include_once( ABSPATH . WPINC . '/class-IXR.php' );
include_once( ABSPATH . WPINC . '/class-wp-http-ixr-client.php');
add_filter( 'http_request_args', function( $args, $url ) {
if ( false !== strpos($url, 'example.backlog.jp') ) {
$args['headers']['Authorization'] = 'Basic '. base64_encode('backlog_user' . ':' . 'backlog_passwd');
}
return $args;
}, 10, 2 );
$ixr_client = new WP_HTTP_IXR_Client( 'https://example.backlog.jp/XML-RPC' );
if ( !$ixr_client->query('backlog.getProjects') ) {
var_dump($ixr_client->getErrorCode());
}
print_r($ixr_client->getResponse());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment