諸葛 接口 調用 學習 简体版
原文   原文鏈接

#coding:utf-8
import json
import requests
from requests.auth import HTTPBasicAuth
""" 老師和學生是不一樣的app_id,學生app_id是xxxx,老師app_id是xxx """json

if name == 'main':api

""" 數據統計API: 新增人數 """
urla = 'https://api.zhugeio.com/v2/stat/xxxx?metrics=users&dimensions=$province&dimensions=$city' \
      '&conditions={"$birth_day":["between","2018-02-01","2018-03-17"],"$province":["==","黑龍江"]}'

""" 學生指標: 登陸次數sessions  """
urlb = 'https://api.zhugeio.com/v2/stat/xxxx?metrics=sessions&dimensions=$province&dimensions=$city' \
      '&conditions={"$day":["between","2018-02-01","2018-03-17"]}'

""" 用戶查詢API: 成功完成老師任務(階梯)"""
urlc = 'https://api.zhugeio.com/v2/app_users/xxx/user/infos?conditions={"relation": "and",' \
      '"event.成功完成老師任務(階梯)": {"$day":["between","2018-03-12","2018-03-18"]}' \
      '}'
'''
""" 如下是學生指標 url: 登陸時長(s) """
url = 'https://api.zhugeio.com/v2/stat/xxxx?metrics=avg_session_length&dimensions=$province' \
      '&conditions={"$day":["between","2018-02-01","2018-03-17"]}'
'''

r = requests.get(urlc, auth=HTTPBasicAuth("1580137xxxx","xxxxxxxxxxf6d74d1fbf7752a76bfbxxxx")).json()
print(r)
print(len(r['results']))
for ele in r['results']:
    print(ele)
相關文章
相關標籤/搜索
每日一句
    每一个你不满意的现在,都有一个你没有努力的曾经。
本站公眾號
   歡迎關注本站公眾號,獲取更多信息