马永占,myz,mayongzhan

相当稳定的进步,欢迎回贴交流

马永占ID:mayongzhan
58714次访问,排名1634好友1人,关注者10
php,apache,mysql,linux,html,css,javascript
mayongzhan的文章
原创 148 篇
翻译 0 篇
转载 0 篇
评论 83 篇
myz的公告

XML聚合
feedsky
最近评论
mayongzhan:很深刻
mayongzhan:为什么黑大能知道这些而我不知道.同样是翻资料...哎差距啊...
MyZ:黑人推荐...去试试
MyZ:点子书还可以,不过大部分都是英文版的
MyZ:不太喜欢读书.感觉浪费钱...读完的书就摆在那浪费,而且占地方....呵呵...
文章分类
收藏
    相册
    存档
    订阅我的博客
    XML聚合  FeedSky

    原创 xmlrpc应用metaweblogAPI收藏

    新一篇: httpview比较:httpwatch,httplook,fiddler,temper data,livehttpheader

    版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章原始出版、作者信息和本声明。否则将追究法律责任。http://blog.csdn.net/mayongzhan - 马永占,myz,mayongzhan

    metaweblogAPI类
    整个项目部分内容,看看意思.其实很简单.关键部分略掉

    Xmlrpc_encode不是那么好用,有的东西不能使用.例如struct类型
    所以如果有需要的话,还是自己写一个xml结构,然后发过去.OK.

    class Send extends SysLOG
    {
     private $blogid = "xxx"; //博ID
     private $username = "xxx"; //用户名
     private $userpassword = "xxx"; //用户密码
     private $url = " http://blog.csdn.net/mayongzhan/services/metablogapi.aspx"; //地址
     
     function __construct($blogid, $username, $userpassword, $url)
     {
      $this->blogid = $blogid;
      $this->username = $username;
      $this->userpassword = $userpassword;
      $this->url = $url;
     }
     
     //添加类别
     public function addCate($cateName)
     {
      //metaWeblog.newCategory 新增类别
      $request = xmlrpc_encode_request(
          'metaWeblog.newCategory',
          array($this->blogid,
            $this->username,
            $this->userpassword,
            $cateName),
          array('encoding' => 'UTF-8')
              );
      return $this->xmlRPCSend($request); //类别ID
     }
     
     //添加文章
     public function addPage($title, $content, $down, $cate)
     {
      略
     }
     
     //其他暂时用不到的操作
     private function otherOP()
     {
      //metaWeblog.getCategories 显示类别
      //metaWeblog.getPost 得到文章
      //metaWeblog.editPost 编辑文章
      //blogger.deletePost 删除文章
      //blogger.getRecentPosts
      //blogger.getUsersBlogs
      //metaWeblog.getCategoryPosts
      //metaWeblog.getPostByID
      //metaWeblog.getRecentPosts
      //metaWeblog.newComment
      //metaWeblog.newMediaObject
      //mt.getCategoryList
      //mt.getPostCategories
      //mt.setPostCategories
     }
     
     private function xmlRPCSend($request)
     {
      try
      {
       $context = stream_context_create(array('http' => array(
       'method' => "POST",
       'header' => "Content-Type: text/xml",
       'content' => $request
       )));
       $file = file_get_contents($this->url, false, $context);
       
       if(!$file) {
        throw new Exception('错误:得不到webservice的response');
       }
       
       $response = xmlrpc_decode($file);
       
       if (is_array($response) && xmlrpc_is_fault($response))
       {
        throw new Exception($response['faultString'],
        $response['faultCode']);
       }
       
       return $response;
      }
      catch (Exception $e)
      {
       $this->sys_log($e->getMessage(), 'errorSend.log');
      }
     }
    }

    发表于 @ 2008年04月19日 23:25:00|评论(loading...)|收藏

    旧一篇: 传说中的zend studio各版本的缺点

    评论:没有评论。

    发表评论  


    登录
    Csdn Blog version 3.1a
    Copyright © myz