Skip to content

Instantly share code, notes, and snippets.

@gracefullight
Created January 15, 2017 08:18
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 gracefullight/adef04998cc59434500a9c346bceb459 to your computer and use it in GitHub Desktop.
Save gracefullight/adef04998cc59434500a9c346bceb459 to your computer and use it in GitHub Desktop.
<?
include_once "xmlrpc.inc";
$title = $_POST['title'];
$content = $_POST['content'];
$result = newPost($title, $content);
echo json_encode($result);
// 블로그 API 함수
function newPost($title, $description) {
$g_blog_url = "https://api.blog.naver.com/xmlrpc";
$user_id = "아이디";
$blogid = "아이디";
$password = "발급받은 비밀번호";
$publish = true;
$client = new xmlrpc_client($g_blog_url);
$client->setSSLVerifyPeer(false);
$GLOBALS['xmlrpc_internalencoding']='UTF-8';
$struct = array(
'title' => new xmlrpcval($title, "string"),
'description' => new xmlrpcval($description, "string")
);
$f = new xmlrpcmsg("metaWeblog.newPost",
array(
new xmlrpcval($blogid, "string"),
new xmlrpcval($user_id, "string"),
new xmlrpcval($password, "string"),
new xmlrpcval($struct , "struct"),
new xmlrpcval($publish, "boolean")
)
);
$f->request_charset_encoding = 'UTF-8';
return $response = $client->send($f);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment