发新话题
打印

[技术分享] wordpress XML-RPC PHP发表带有html代码的文章

wordpress XML-RPC PHP发表带有html代码的文章

复制内容到剪贴板
代码:
<?php
  include("xmlrpc.inc");
  $c = new xmlrpc_client("wordpress/xmlrpc.php", "localhost", 80);
  $content['title']="XMLRPC Post";  //标题
  $content['description']="<a href="https://addons.mozilla.org/zh-CN/firefox/downloads/file/1854/betfair_toolbar-0.0.3-fx.xpi">gdfgt</a>"; //内容
  $content['wp_author_id']="1";  //发帖人ID
  $content['mt_keywords']="878,787";  //标签
  $content['wp_password']="";  //文章密码,输入后显示加密
  $content['categories'] = array("2"); //分类名
  $x = new xmlrpcmsg("metaWeblog.newPost",
                      array(php_xmlrpc_encode("1"),
                      php_xmlrpc_encode("admin"),  //用户名
                      php_xmlrpc_encode("admin"),  //密码
                      php_xmlrpc_encode($content),
                      php_xmlrpc_encode("1")));

  $c->return_type = 'phpvals';
  $r =$c->send($x);
  if ($r->errno=="0")
    echo "Successfully Posted";
  else {
    echo "There are some error";
    print_r($r);
  }
?>
[ 本帖最后由 119977 于 2008-10-7 13:19 编辑 ]
附件: 您所在的用户组无法下载或查看附件

TOP

你到底是要做什么?不明白你说的

TOP

发新话题