| 제목 | xmlrpc 사용 문의 | ||
|---|---|---|---|
| 글쓴이 | sisco | 작성시각 | 2010/06/16 11:49:15 |
|
|
|||
|
네이버 글 포스팅을 위해 xmlrpc를 사용하고자 합니다. controller/blogapi.php
class BlogAPI extends Controller{
function BlogAPI(){
parent::Controller();
$this->load->model('blogapi_model');
}
function send_data(){
$this->blogapi_model->send_req();
}
}
model/blogapi_model.php
class BlogAPI_model extends Model{
function BlogAPI_model(){
parent::Model();
$this->load->library('xmlrpc');
}
function send_req(){
$this->xmlrpc->set_debug(TRUE);
$this->xmlrpc->server("https://api.blog.naver.com/xmlrpc");
$this->xmlrpc->method('metaWeblog.newPost');
$struct = array(
"title" => array('aa', 'string'),
"description" => array('bbb', 'string'),
"tags" => array('tags', 'string')
);
$request = array (
array("ssssss", "string"),
array("ssssss", "string"),
array("xxxxxxxxxxxxxxxx", "string"),
array($struct, "struct"),
array(TRUE, "boolean")
);
$this->xmlrpc->request($request);
if ($this->xmlrpc->send_request()) {
echo "success";
} else {
echo $this->xmlrpc->display_error();
}
}
}
--$request의 ssssss는 네이버 아이디, xxxxxxxxxxxxxxxxxx는 블로그 API발급 비번입니다.블로그 API발급 비번은 블로그->관리>글.메뉴관리->플러그인.연동관리->글쓰기API설정 에서 발급가능합니다. 이렇게 작성하고 http://도메인/blogapi/send_data 라고 브라우저에 치면 ---DATA--- HTTP/1.1 301 Moved Permanently Date: Wed, 16 Jun 2010 02:39:21 GMT Server: Apache/2.0.54 (Unix) mod_jk/1.2.14 mod_ssl/2.0.54 OpenSSL/0.9.7a Location: http://api.blog.naver.com/xmlrpc/ Content-Length: 241 Connection: close Content-Type: text/html; charset=iso-8859-1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>301 Moved Permanently</title> </head><body> <h1>Moved Permanently</h1> <p>The document has moved <a href="http://api.blog.naver.com/xmlrpc/">here</a>.</p> </body></html> ---END DATA---Did not receive a '200 OK' response from remote server. (HTTP/1.1 301 Moved Permanently) 이렇게 나옵니다. 뭐가 잘못된 겁니까 ㅠ.ㅠ |
|||
| 다음글 | twtkr 처럼 아이디 비밀번호를 받아서 트위터로그인처... (5) | ||
| 이전글 | 액티브 레코드 select 시에 원치 않는 이스케이프 (3) | ||
|
sisco
/
2010/06/16 12:12:18 /
추천
0
|
|
변종원(웅파)
/
2010/06/16 12:48:11 /
추천
0
ssl에 대한 설정이 없네요.
에러 메세지도 https 로 보냈더니 http로 옮겨졌다고 나오는걸로 봐서 ssl관련 문제인것 같습니다. 아래 문서에서 ssl관련 설정 한번 보세요. http://blog.naver.com/boxcj?Redirect=Log&logNo=150069709217 |
include_once("./xmlrpc.inc"); $GLOBALS["xmlrpc_internalencoding"] = "UTF-8"; $API_url = "https://api.blog.naver.com/xmlrpc"; $API_id = "sssssss"; $API_pw = "xxxxxxxxxxxxxxxxxxxxxxxx"; $XmlClient = new xmlrpc_client($API_url); $Struct = array( "title" => new xmlrpcval("타이틀", "string"), "description" => new xmlrpcval("내용", "string"), "tags" => new xmlrpcval("태그", "string") ); $Msg = new xmlrpcmsg("metaWeblog.newPost", array( new xmlrpcval($API_id, "string"), new xmlrpcval($API_id, "string"), new xmlrpcval($API_pw, "string"), new xmlrpcval($Struct, "struct"), new xmlrpcval(TRUE, "boolean") ) ); $XmlClient->send($Msg);이코드는 실행됩니다. 이걸 CI용으로 하려면.. 어찌해야합니까.. 위에는 머가 잘못됐을까요..