Skip to content
조회 수 12760 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

MetaWeblog API in PHP

Blogger API Tutorial: How To Get Your Blog’s Posts



Your Blog’s ID

Each blog has its own ID from which we can get the posts feed. To get your blog’s id simply open up your dashboard and click “New Post”, your blog id will then be visible in the URL.

blogger blog id

Blog ID in URL

How to Get The Posts With PHP

The URL for a blog’s feed has the following format.

http://www.blogger.com/feeds/blogID/posts/default

If you take this URL, put your blog’s id and paste navigate to it in your browser, you will see that you get an XML response with your posts.

This XML response has an <entry> tag for each one the posts. Inside the entry tag there are other tags such as <title>,<content>, <published> and more. These are the tags we will refer to in our PHP script.

How To Read The Response

Here is a simple PHP script you can use to display your posts’ title, content and published date. If you want to learn about reading XML files in detail check out my post on this subject.
How To Read an XML File From a URL

<?php
$blogID='xxxxxxxxxxx';
$requestURL="http://www.blogger.com/feeds/{$blogID}/posts/default";
$xml=simplexml_load_file($requestURL);
?>
<html>
<body>
<?php
foreach($xml->entry as $post)
{
echo '<div>';
echo '<h2>'.$post->title.'</h2>'; // post title
echo '<p>Published: '.$post->published.'</p>'; // date published
echo '<p>'.$post->content.'</p>'; // post content
echo '</div>';
}
?>
</body>



Implementation of the MetaWeblog API http://www.xmlrpc.com/metaWeblogApi in PHP.

<?php
/**
 * Skeleton file for MetaWeblog API http://www.xmlrpc.com/metaWeblogApi in PHP
 * Requires Keith Deven's XML-RPC Library http://keithdevens.com/software/xmlrpc and store it as xmlrpc.php in the same folder
 * Written by Daniel Lorch, based heavily on Keith Deven's examples on the Blogger API.
 */

require_once dirname(__FILE__) . '/xmlrpc.php';

function metaWeblog_newPost($params) {
  list($blogid, $username, $password, $struct, $publish) = $params;
  $title = $struct['title'];
  $description = $struct['description'];


  // YOUR CODE:
  $post_id = 0; // id of the post you just created


  XMLRPC_response(XMLRPC_prepare((string)$post_id), WEBLOG_XMLRPC_USERAGENT);
}

function metaWeblog_editPost($params) {
  list($postid, $username, $password, $struct, $publish) = $params;


  // YOUR CODE:
  $result = false; // whether or not the action succeeded


  XMLRPC_response(XMLRPC_prepare((boolean)$result), WEBLOG_XMLRPC_USERAGENT);
}

function metaWeblog_getPost($params) {
  list($postid, $username, $password) = $params;
  $post = array();


  // YOUR CODE:
  $post['userId'] = '1';
  $post['dateCreated'] = XMLRPC_convert_timestamp_to_iso8601(time());
  $post['title'] = 'Replace me';
  $post['content'] = 'Replace me, too';
  $post['postid'] = '1';


  XMLRPC_response(XMLRPC_prepare($post), WEBLOG_XMLRPC_USERAGENT);
}

function XMLRPC_method_not_found($methodName) {
  XMLRPC_error("2", "The method you requested, '$methodName', was not found.", WEBLOG_XMLRPC_USERAGENT);
}

$xmlrpc_methods = array(
  'metaWeblog.newPost'  => 'metaWeblog_newPost',
  'metaWeblog.editPost' => 'metaWeblog_editPost',
  'metaWeblog.getPost'  => 'metaWeblog_getPost'
);

$xmlrpc_request = XMLRPC_parse($HTTP_RAW_POST_DATA);
$methodName = XMLRPC_getMethodName($xmlrpc_request);
$params = XMLRPC_getParams($xmlrpc_request);

if(!isset($xmlrpc_methods[$methodName])) {
  XMLRPC_method_not_found($methodName);
} else {
  $xmlrpc_methods[$methodName]($params);
}
?>






로그인 후 댓글쓰기가 가능합니다.

?

  1. 11
    Aug 2010
    12:04

    [엑셀함수] 조건결과가 참일경우만 정상 출력하기

    Category컴퓨터잡담 Views8348
    Read More
  2. 11
    Aug 2010
    10:00

    [악성코드퇴치] fph.exe 프로세서 제거하기

    Category컴퓨터잡담 Views12594
    Read More
  3. 28
    Jul 2010
    08:39

    엑셀 색깔 지정 함수

    Category컴퓨터잡담 Views65609
    Read More
  4. 27
    Jul 2010
    15:50

    메모리 용량이 넉넉하다면 램디스크를 한번 써보라,

    Category컴퓨터잡담 Views5408
    Read More
  5. 23
    Jul 2010
    12:06

    [엑셀] 날짜와 요일 표현하기

    Category컴퓨터잡담 Views23927
    Read More
  6. 23
    Jul 2010
    10:49

    도스 텍스트 TXT 파일에 내용 추가하기

    Category컴퓨터잡담 Views5952
    Read More
  7. 23
    Jul 2010
    10:47

    윈도 로그인하기 전에 배치파일을 실행하는 방법

    Category컴퓨터잡담 Views18232
    Read More
  8. 23
    Jul 2010
    10:43

    윈도우 서비스 수동 등록 방법

    Category컴퓨터잡담 Views9628
    Read More
  9. 22
    Jul 2010
    16:59

    미국판 싸이월드라고 하는 페이스북 CEO 마크 주커버그

    Category컴퓨터잡담 Views6543
    Read More
  10. 22
    Jul 2010
    08:41

    아이폰에서의 dns설정 방법 (유툽 속도 향상 법)

    Category컴퓨터잡담 Views11835
    Read More
  11. 14
    Jul 2010
    19:20

    엑셀 - 초과 근무시간 계산

    Category컴퓨터잡담 Views20084
    Read More
  12. 12
    Jul 2010
    17:18

    Implementation of the MetaWeblog API http://www.xmlrpc.com/metaWeblogApi in php

    Category컴퓨터잡담 Views12760
    Read More
  13. 11
    Jul 2010
    22:07

    AutohotKey Postmessage(SendMessage)로 CTRL+C 전송하기

    Category컴퓨터잡담 Views21413
    Read More
  14. 10
    Jul 2010
    06:57

    MouseOver - Background color, 마우스오버시 백그라운드 컬러 지정

    Category컴퓨터잡담 Views11032
    Read More
  15. 09
    Jul 2010
    07:59

    악의적 호출 방지용 Referer 체크

    Category컴퓨터잡담 Views7530
    Read More
  16. 07
    Jul 2010
    11:57

    APMSetup에서 문서 출력 순서 등 설정

    Category컴퓨터잡담 Views14066
    Read More
  17. 05
    Jul 2010
    23:19

    CSS를 이용한 DIV 둥근 테두리 만들기.

    Category컴퓨터잡담 Views11710
    Read More
  18. 03
    Jul 2010
    15:53

    둥근 모서리 박스 자동 생성

    Category컴퓨터잡담 Views6311
    Read More
  19. 03
    Jul 2010
    10:43

    마우스 오버시 DIV 레이어 감추기 / 보이기

    Category컴퓨터잡담 Views15931
    Read More
  20. 03
    Jul 2010
    10:17

    JavaScript1.2 Event mouse css 제어

    Category컴퓨터잡담 Views7514
    Read More
Board Pagination Prev 1 ... 38 39 40 41 42 ... 46 Next
/ 46

http://urin79.com

우린친구블로그

sketchbook5, 스케치북5

sketchbook5, 스케치북5

나눔글꼴 설치 안내


이 PC에는 나눔글꼴이 설치되어 있지 않습니다.

이 사이트를 나눔글꼴로 보기 위해서는
나눔글꼴을 설치해야 합니다.

설치 취소