Created
January 15, 2017 08:18
-
-
Save gracefullight/adef04998cc59434500a9c346bceb459 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
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