2017 © Pedro Peláez
 

library metaweblog

通过MetaWeblog协议同时管理51cto,csdn,sina,163,oschina,cnblogs等博客

image

apanly/metaweblog

通过MetaWeblog协议同时管理51cto,csdn,sina,163,oschina,cnblogs等博客

  • Wednesday, November 9, 2016
  • by apanly
  • Repository
  • 2 Watchers
  • 3 Stars
  • 21 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

MetaWeblog

主要作用

  • 通过MetaWeblog协议同时管理51cto,csdn,sina,163,oschina,cnblogs等博客

支持博客

  • 51cto
  • csdn
  • sina
  • 163
  • oschina
  • cnblogs
  • chinaunix

主要功能

  • 实现了发表新文章
  • 实现了编辑文章

安装

composer require apanly/metaweblog

使用

$url = "https://my.oschina.net/action/xmlrpc";
$target = new \apanly\metaweblog\MetaWeblog( $url );
$username = "xxx";
$passwd = "xxx";
$target->setAuth( $username,$passwd );

$blog_id = 784865;//等执行了发布新文章之后就会有这个值了

if( $blog_id ){
    $params = [
        'title'=> '测试博文标题--编辑',
        'description'=> '测试博文内容--编辑',
        'categories'=> [ 1 ]
    ];
    if( !$target->editPost( $blog_id,$params ) ){
        var_dump( $target->getErrorMessage() );
    }
}else{
    $params = [
        'title'=> '测试博文标题',
        'description'=> '测试博文内容',
        'categories'=> [ 1 ]
    ];
    if( $target->newPost( $params ) ){
        $blog_id = $target->getBlogId();
        var_dump( $blog_id );
    }else{
        var_dump( $target->getErrorMessage() );
    }
}

截图

  • 新文章
  • 编辑文章

ToDoList

  • 目前代码比较冗余,后续改的更优雅点

Lecense

PHP Browser is licensed under The MIT License (MIT)., (*1)

参考资料

The Versions

09/11 2016

dev-master

9999999-dev http://www.vincentguo.cn

通过MetaWeblog协议同时管理51cto,csdn,sina,163,oschina,cnblogs等博客

  Sources   Download

MIT

The Requires

  • php ^5.3.3 || ^7.0

 

by Avatar apanly

sina metaweblog 51cto csdn oschina cnblogs 同步博文