Discuz API JSON 適用於IOS及Android移動端開發
Discuz API 搭建
下載API文件:鏈接: http://pan.baidu.com/s/1mir1zkc 密碼: 4fyj
將appapi文件夾放入DZ目錄下執行 http://xxxx.com/appapi/install.php
執行瀏覽器出現 「安裝成功」 字樣可進行下面的操作
目錄結構
<appapi>
├connect.php
├image.php
├inc.php
├index.php//首頁控制器 index.php?mod=index&XXX
├install.php//安裝文件,建議安裝完成後刪除。
├login.php //登錄獲取Token,裡邊也包括登錄後用戶的信息。
├register.php
├<config>
│ ├config.php
│ ├config_extra.php
│ ├permission_config.php
│ └smiley_map.php
├<lib>
│ ├class_member.php
│ ├json.class.php
│ ├lib_app_helper_attach.php
│ ├lib_appversion.php
│ ├lib_bfd_app.php
│ ├lib_bfd_perm.php
│ └lib_bfd_user.php
├<qqconnect>
│ ├connect.class.php
│ ├index.htm
│ ├qqshow.inc.php
│ ├spacecp.inc.php
│ ├<connect>
│ │ ├connect_check.php
│ │ ├connect_config.php
│ │ ├connect_feed.php
│ │ ├connect_login.php
│ │ ├connect_user.php
│ │ └index.htm
│ ├<table>
│ │ ├index.htm
│ │ ├table_common_connect_guest.php
│ │ ├table_common_member_connect.php
│ │ ├table_connect_disktask.php
│ │ ├table_connect_feedlog.php
│ │ ├table_connect_memberbindlog.php
│ │ ├table_connect_postfeedlog.php
│ │ └table_connect_tthreadlog.php
│ ├<template>
│ │ ├extend_common.css
│ │ ├extend_module.css
│ │ ├index.htm
│ │ ├module.htm
│ │ ├qqshow.htm
│ │ └spacecp.htm
├<source>
│ ├bfd_app_favorite_action.php
│ ├bfd_app_favorite_list.php
│ ├bfd_app_forum_list.php
│ ├bfd_app_forum_misc.php
│ ├bfd_app_group_action.php
│ ├bfd_app_group_all.php
│ ├bfd_app_group_index.php
│ ├bfd_app_group_info.php
│ ├bfd_app_group_my.php
│ ├bfd_app_group_thread.php
│ ├bfd_app_group_thread2.php
│ ├bfd_app_index.php
│ ├bfd_app_index_threads.php
│ ├bfd_app_index2.php
│ ├bfd_app_post_newthread.php
│ ├bfd_app_post_reply.php
│ ├bfd_app_search.php
│ ├bfd_app_send_pm.php
│ ├bfd_app_sign.php
│ ├bfd_app_space_notice.php
│ ├bfd_app_space_pm.php
│ ├bfd_app_space_thread.php
│ ├bfd_app_thread_activity.php
│ ├bfd_app_tip.php
│ ├bfd_app_tip_message.php
│ ├bfd_app_topicadmin.php
│ ├bfd_app_user_action.php
│ ├bfd_app_user_avatar.php
│ ├bfd_app_user_detail.php
│ ├bfd_app_user_follow.php
│ ├bfd_app_user_friend.php
│ ├bfd_app_user_space.php
│ ├bfd_app_userinfo.php
│ ├<include>
│ │ ├thread_activity.php
│ │ ├thread_activity_form.htm
│ │ ├thread_poll.php
│ │ └viewthread_activity.htm
│ ├<search>
│ │ ├index.htm
│ │ ├search_album.php
│ │ ├search_blog.php
│ │ ├search_collection.php
│ │ ├search_forum.php
│ │ ├search_group.php
│ │ ├search_my.php
│ │ ├search_portal.php
│ │ └search_user.php
│ ├<topicadmin>
│ │ ├topicadmin_delpost.php
│ │ └topicadmin_moderate.php
├<template>
│ ├footer.htm
│ ├header.htm
│ ├register.htm
│ ├seccheck.htm
│ ├<style>
│ │ ├common.js
│ │ ├jquery-1.8.3.min.js
│ │ ├style.css
│ │ ├<images>
│ │ │ ├login.png
│ │ │ └login_on.png
├<unit_test>
│ ├test.php
│ ├test_config.php
│ ├test_function.php
│ ├test_inc.php
│ └test_send_pm.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
登錄Token獲取
我們想要獲取用戶的詳細信息和發帖就要給存儲一個Token Cookis Login.php 用戶登錄
打開Login我們可以看到。
$username = urldecode($_POST["username"]);
$password = $_POST["password"];
1
2
我們只需要以POST傳入這兩個變數的值即可進行登錄操作,話不多話看我直接貼代碼。
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<span id="msg"></span>
<input type="txt" name="name">
<input type="txt" name="mm">
<button onclick="test();">按鈕</button>
</body>
<script src="//cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
<script>
function test(){
var mm=$("name").val()
var name=$("mm").val()
$.ajax({
//提交數據的類型 POST GET
type:"GET",
//提交的網址
url:"../dz/appapi/login.php",
//提交的數據
data:{username:name,password:mm},
//返回數據的格式
datatype: "json",//"xml", "html", "script", "json", "jsonp", "text".
//在請求之前調用的函數
beforeSend:function(){$("#msg").html("logining");},
//成功返回之後調用的函數
success:function(data){
$("#msg").html(decodeURI(data));
} ,
//調用執行後調用的函數
complete: function(XMLHttpRequest, textStatus){
alert(XMLHttpRequest.responseText);
alert(textStatus);
//HideLoading();
},
//調用出錯執行的函數
error: function(){
//請求出錯處理
}
});
}
</script>
</html>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
JSON返回值
返回用戶基本的頭像,用戶名,郵箱,以及其他信息,這些輸出都可以在源文件里進行修改的。
{"errornum":"E00000","errormsg":"u7528u6237u767bu5f55u6210u529f","data":{"uid":"1","avatar":"http://127.0.0.1/dz/uc_server/avatar.php?uid=1&size=middle","username":"admin","email":"admin@admin.com","password":"a5ecf2332da38601e6fadd79ee69840f","groupid":"1","extcredits1":"0","extcredits2":"2","follower":"0","following":"0","gender":"u4fddu5bc6","department":"","constellation":"","medals":[],"bloodtype":"","sightml":"","token":"65faMdFDBMcsPpO3zghoLJIAsBLOFRNbOU61rjVZsCYtN8zAlOoW4hbRUno4fufoxtbtwuJX1L+iur97LFjWVnkBow17h/vAnGk","token_expire":"1493655981"}}
1
我們最主要是要取到用戶唯一Token。
"token":"65faMdFDBMcsPpO3zghoLJIAsBLOFRNbOU61rjVZsCYtN8zAlOoW4hbRUno4fufoxtbtwuJX1L+iur97LFjWVnkBow17h/vAnGk"
1
然後我們寫入到Cookis 裡邊兒,就可以進行index.php?mod里的其他操作啦。我們這裡只是粗略的說了一下用法,具體的一些API文檔的用法LIB對應的控制器都有說明的,還有不懂得地方,請給我留言。


※Spring Boot 2.0 版的開源項目雲升級所帶來的新內容
※ASP Server 對象
TAG:程序員小新人學習 |