Advertisement
Guest User

Untitled

a guest
Apr 30th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. def get(self, method, **kwargs):
  2. all_params = get_params_from_kwargs(self.params, kwargs)
  3. host = self.host if (all_params["host"] is None) else all_params["host"]
  4. answer = None
  5. if (method.startswith("http")):
  6. all_params = get_params_from_url(method)
  7. if (not "client_id" in method):
  8. method += "&client_id=" + scbot_consts.official_sc_client_id
  9. answer = requests.get(method, headers=client_header)
  10. else:
  11. answer = requests.get(host + method, params=all_params["params"], headers=client_header)
  12. try:
  13. json = answer.json()
  14. try:
  15. next_href = json.get("next_href")
  16. if (not next_href):
  17.  
  18. json["next_href"] += "&oauth_token=" + all_params["oauth_token"]
  19. except:
  20. pass
  21. return json
  22. except:
  23. return answer.text
  24.  
  25. def post(self, method, **kwargs):
  26. all_params = get_params_from_kwargs(self.params, kwargs)
  27. host = self.host if (all_params["host"] is None) else all_params["host"]
  28. answer = None
  29. if (method.startswith("http")):
  30. all_params = get_params_from_url(method)
  31. if (not "client_id" in method):
  32. method += "&client_id=" + scbot_consts.official_sc_client_id
  33. answer = requests.post(method, headers=client_header)
  34. else:
  35. answer = requests.post(host + method, params=all_params["params"], headers=client_header)
  36. try:
  37. json = answer.json()
  38. try:
  39. next_href = json.post("next_href")
  40. if (not next_href):
  41.  
  42. json["next_href"] += "&oauth_token=" + all_params["oauth_token"]
  43. except:
  44. pass
  45. return json
  46. except:
  47. return answer.text
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement