Itop REST/JSON services 验证登陆方法
来源:互联网 发布:2018程序员考试时间 编辑:程序博客网 时间:2024/05/22 13:34
简介:
进入API操作的第一步就是登陆,网上资源很少,在些做个总结,转载请注明出处
http://blog.mreald.com/180
1.WEB上验证 api
地址:http://jsfiddle.net/U6qwK/6/
输入你的URL、Login_name、Password ,查看调用结果(支持本地验证哦!)
2.通过Curl 命令行验证
curl -X POST -H
'Content-Type:application/x-www-form-urlencoded; charset=UTF-8'
-d
'auth_user=itop&auth_pwd=213xxx&json_data=%7B%22operation%22%3A%22list_operations%22%7D'
"http://IP/web/webservices/rest.php?version=1.3"
或者
curl -X POST -H
'Content-Type:application/x-www-form-urlencoded; charset=UTF-8'
-d
'json_data={"operation": "list_operations"}'
-d
'auth_user=itop&auth_pwd=1cc0zx'
http:
//100
.713.191.60
/web/webservices/rest
.php?version=1.3
3. 写python 脚本验证
#!/usr/local/bin/python
#coding:utf-8
import
urllib
import
urllib2
import
json
def
http_post():
url
=
"http://100.173.191.60/web/webservices/rest.php?version=1.3"
auth
=
{
"auth_user"
:
"itop"
,
"auth_pwd"
:
"2134xxzx"
}
opr
=
{
"operation"
:
"list_operations"
}
oprjson
=
urllib.urlencode({
'json_data'
: json.dumps(opr)} )
jdata
=
urllib.urlencode(auth)
jdata
=
jdata
+
'&'
+
oprjson
response
=
urllib.urlopen(url,jdata)
return
response.read()
rep
=
http_post()
print
rep
执行结果:
问题:
1.必须分开用户与json_data, 比如下面就不会成功
curl -X POST -H
'Content-Type:application/x-www-form-urlencoded; charset=UTF-8'
-d
'{"auth_user":"itop","auth_pwd":"211cc0zx", "json_data":{"operation":"list_operations"}}'
http:
//100
.173.191.60
/web/webservices/rest
.php?version=1.3
2. curl 的-H 选项可以不要
也可以换成 -H "Content-Type: application/json" 。 浏览器默认会变成最 -H 'Content-Type:application/x-www-form-urlencoded; charset=UTF-8'
参考资料:
https://wiki.openitop.org/doku.php?id=2_2_0:advancedtopics:rest_json#dokuwiki__top
1 0
- Itop REST/JSON services 验证登陆方法
- Parsing REST Services JSON Responses (C#)
- springmvc+velocity+ Rest Services(xml,json)实例
- springmvc+velocity+ Rest Services(xml,json)实例
- 登陆界面json方法 ajax请求,时间戳验证码、cookie记住密码、登陆判断
- REST Web Services
- NodeJs使用json web token验证REST服务
- 防止用户重复登陆的验证方法
- 看Discuz的登陆验证方法
- REST vs SOAP Web Services
- Rest风格的Web Services
- extJs+json实现的一个登陆验证的简单例子
- Struts2+jquery+ajax+json实现无刷新登陆验证.
- 测试RESTful Web Services的三种方法(推荐Simple REST Client)
- WSO2 ——(6)开发几种services的方法:SOAP与REST
- WSO2 ——(6)开发几种services的方法:SOAP与REST
- 登陆验证
- 登陆验证
- redhat6.5下配置安装yum源
- php截取逗号之前的字符
- c static关键字描述
- PHP实现乘法表
- Spring MVC 4 学习4:Bean装配例子
- Itop REST/JSON services 验证登陆方法
- iOS技术开发之路
- UIScreen(屏幕)、UIWindow(画框)、UIView(画布)、didFinishLaunchingWithOptions、UIViewController各个方法的加载顺序
- [图像] 直方图的距离
- 'libxml/tree.h' file not found
- 常用Android开发组件之文本类组件
- Linux定时任务执行crontab
- uva 699
- 输入流和输出流的理解