Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
下面是 python3 的範例 裡面有我的key 理論上只要我人在這邊,應該都可以取到資料
python3 : Get all resource
#!/usr/bin/env python3 ############################################ # getAllResource.py # Author: William Ho # Date: 2016/06 # Brief: Get current endpoints from mbed Device Connector with API ############################################ from urllib.request import Request, urlopen print("We will get all activity endpoints...") URI='https://api.connector.mbed.com/endpoints/b963e35d-2f14-4142-a556-1e0e45cf0efc/' AUTH_MSG ='Authorization' AUTH_VALUE = 'Bearer raMSWYiC6FCDp3EKU0JjI2CBG4oYDQvt3Bv58hKKWBwPIwf24AxEE1syhaM1npHFC5jQr5QMkGDKsQXotCNDDj6nGNC32sKX8vYA' req = Request(URI) req.add_header(AUTH_MSG, AUTH_VALUE) data = urlopen(req) print(data.read()) print("\n\nThat's all")順利的話可以拿到這樣的結果
Note
We will get all activity endpoints... b'[{"uri":"/analog_sensor/0/axis_sensor","rt":"Sensor","obs":true,"type":""},{"uri":"/led_blink/0/blinker","rt":"Blink","obs":false,"type":""},{"uri":"/led_blink/0/blink_4times","rt":"Pattern","obs":false,"type":""},{"uri":"/digital_inp/0/buttoni_1","rt":"Button","obs":true,"type":""},{"uri":"/3/0","obs":false,"type":""}]'