资讯专栏INFORMATION COLUMN

Wiz笔记SDK 0.1

wangxinarhat / 1481人阅读

替wiz笔记写了一个sdk,https://github.com/jiankers/WizSDK
主要功能介绍:

登录wiz。

提取用户信息。

提取笔记目录列表。

提取笔记列表。

提取笔记内容。

谁需要fork吧


debug = true; //登录 $info = $wiz->login(); $token = $info["token"]; $kb_guid = $info["kb_guid"]; //获取用户信息 $userinfo = $wiz->getUserInfo($token); //获取目录列表 $dirinfo = $wiz->getDirList($token, $kb_guid); if(!isset($_GET["dir"]) && !isset($_GET["id"])){ echo ""; } if(isset($_GET["dir"])){ //获取每个目录下笔记列表 $doclist[] = $wiz->getDirDocList($token, $kb_guid, $_GET["dir"]); echo ""; } if(isset($_GET["id"])){ $document_guid = $_GET["id"]; $info = $wiz->getDirDocShow($token, $kb_guid, $document_guid); //针对wiz笔记图片相对路径进行补全 echo preg_replace ( "/src="/unzip//", "src="http://beta.note.wiz.cn/unzip/", $info["document_info"]["document_body"] ); }

WizSDK.class.php


* @license http://www.php0.net/ * @version 0.1 * @lastmodify 2013-10-25 */ class WizSDK{ private $apiurl = "http://beta.note.wiz.cn"; private $username = ""; private $passwd = ""; public $debug = true; //开启debug则每次都执行登录 function __construct($username,$passwd){ $this->username = $username; $this->passwd = $passwd; } /** * 登录验证 * 该方法执行一次即可,因为wiz笔记内部不需要验证登录,此方法的作用是获取token&kb_guid备其他方法使用 */ public function login(){ if(!file_exists("./user.ini") || $this->debug == false){ ob_start();//开启缓存 //登陆认证 $url = "http://note.wiz.cn/api/login"; $post_data = array( "user_id" =>$this->username,"password" =>$this->passwd,"isKeep_password"=>"off","debug"=>""); $cookie_jar = tempnam("./temp","cookie");//存放COOKIE的文件 $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_jar); //保存cookie信息 curl_exec($ch); curl_close($ch); $json = ob_get_contents(); //写进配置文件 @file_put_contents("./user.ini",$json); ob_clean(); }else{ $json = file_get_contents("./user.ini"); } return json_decode($json,true); } //获取用户信息 public function getUserInfo($token){ $token = isset($_GET["token"])?$_GET["token"]:$token; $url = $this->apiurl."/api/user/info?client_type=web2.0&api_version=3&token={$token}&_=1385364125279"; $info = @file_get_contents($url); return json_decode($info,true); } //获取目录列表 public function getDirList($token, $kb_guid){ $token = isset($_GET["token"])?$_GET["token"]:$token; $kb_guid = isset($_GET["kb_guid"])?$_GET["kb_guid"]:$kb_guid; $url = $this->apiurl."/api/category/all?client_type=web2.0&api_version=3&token={$token}&kb_guid={$kb_guid}&_=1385364126264"; $info = @file_get_contents($url); return json_decode($info,true); } //获取目录下文章列表 public function getDirDocList($token, $kb_guid, $dir){ $token = isset($_GET["token"])?$_GET["token"]:$token; $kb_guid = isset($_GET["kb_guid"])?$_GET["kb_guid"]:$kb_guid; $dir = isset($_GET["dir"])?urlencode($_GET["dir"]):$dir; $url = $this->apiurl."/api/document/list?client_type=web2.0&api_version=3&token={$token}&action_cmd=category&action_value={$dir}&kb_guid={$kb_guid}&_=1385366664005"; $info = @file_get_contents($url); return json_decode($info,true); } //获取目录下文章详情 public function getDirDocShow($token, $kb_guid, $document_guid){ $token = isset($_GET["token"])?$_GET["token"]:$token; $kb_guid = isset($_GET["kb_guid"])?$_GET["kb_guid"]:$kb_guid; $document_guid = isset($_GET["document_guid"])?$_GET["document_guid"]:$document_guid; $url = $this->apiurl."/api/document/info?client_type=web2.0&api_version=3&token={$token}&kb_guid={$kb_guid}&document_guid={$document_guid}&_=1385370541346"; $info = @file_get_contents($url); return json_decode($info,true); } }

文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/20624.html

相关文章

  • GitNote 基于 Git 的跨平台笔记软件正式发布

    摘要:基于的跨平台笔记软件为什么自从工作之后我开始进行笔记记录这是一个很棒的习惯我曾经使用过麦库等都是一些不错的笔记软件但是都有一些各式各样的问题不能满足我的使用年我用编写了第一款笔记软件支持和富文本编辑器但是没有云同步功能年我用和编写了一个编辑 GitNote 基于 Git 的跨平台笔记软件 为什么 自从工作之后,我开始进行笔记记录,这是一个很棒的习惯.我曾经使用过 EDiary Ever...

    liaosilzu2007 评论0 收藏0
  • NoSQL数据库漏洞可导致数据泄露 影响成千上万Microsoft Azure客户

    摘要:研究团队于月日向微软报告了这一问题,之后微软在负责的披露后小时内采取措施缓解了这一问题,并于月日向发现者奖励了万美元的奖金。虽然微软通知了超过的客户潜在的安全漏洞,但预计实际的数字要高得多,因为该漏洞已经被利用了几个月。 .markdown-body{word-break:break-word;line-height:1.75;font-weight:400;font-size:1...

    Integ 评论0 收藏0
  • UAPI-SDK 示例代码使用

    摘要:示例代码使用操作步骤进入产品,选择需要使用的。填写相关字段。查看示例代码,选择语言,即可获得该语言的代码获取账户公私钥替换示例代码中的及复制代码,并在本地运行,即可获得相应的查询结果。SDK 示例代码使用操作步骤Step1:进入UAPI产品,选择需要使用的API。Step2:填写相关字段。以 获取弹性IP信息-DescribeEIP为例,查询账户中北京二地域某一项目的EIP资源列表。Step...

    ernest.wang 评论0 收藏0

发表评论

0条评论

wangxinarhat

|高级讲师

TA的文章

阅读更多
最新活动
阅读需要支付1元查看
<