-
-
Save JMdoubleU/b1871c6d4e86f7b3d5d7046c99b246b5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
url = "http://159.203.178.9/rpc.php" | |
token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJub25lIn0.eyJpZCI6MX0.t4M7We66pxjMgRNGg1RvOmWT6rLtA8ZwJeNP-S8pVak" | |
GET = requests.get | |
POST = requests.post | |
def request(r, params=None, json=None): | |
headers = {'Authorization': token, 'Accept': 'application/notes.api.v2+json'} | |
resp = r(url, params=params, json=json, headers=headers) | |
try: | |
return resp.json() | |
except: | |
return resp | |
def getNotesMetadata(): | |
return request(GET, params={'method': 'getNotesMetadata'}) | |
def getNote(note_id): | |
return request(GET, params={'method': 'getNote', 'id': note_id}) | |
def createNote(note, note_id=None): | |
if note_id is None: | |
return request(POST, params={'method': 'createNote'}, json={'note': note}) | |
else: | |
return request(POST, params={'method': 'createNote'}, json={'id': note_id, 'note': note}) | |
def resetNotes(): | |
return request(POST, params={'method':'resetNotes'}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment