<?php
include_once '
xmlrpc.inc'; // 파일 첨부함.

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); // 
기본값은 true인데, false 설정하지 않으면 SSL 에러남.
$GLOBALS['xmlrpc_internalencoding']='UTF-8′; //
기본값은 ISO-8859-1, 기본값 사용시 한글 깨짐.

$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';

//echo '<pre>'; print_r($f); exit;

return $response = $client->send($f);
}

$return = newPost('test naver rpc', iconv('EUC-KR', 'UTF-8', 'testtestetstest..한글 출력…'));
echo '<pre>';
print_r($return);
?>

2017/02/10 22:52 2017/02/10 22:52

Trackback Address :: https://youngsam.net/trackback/1823