Ejemplo n.º 1
0
import data

# parameters to connect to db
db = mysql.connector.connect(
	host = data.get_mysql_host(),
	user = data.get_mysql_user(),
	passwd = data.get_mysql_passwd(),
	database = data.get_mysql_database()
)

# authentification to api.swgoh.help
headers_auth = {
	"method": "post",
	"content-type": "application/x-www-form-urlencoded"
}
data = data.get_swgoh_connection_data()


# sending request to obtain the token
if len(sys.argv) > 2:
	token_str = "Bearer " +sys.argv[2]
else:
	auth = requests.post("https://api.swgoh.help/auth/signin", data=data, headers=headers_auth)
	token_str = "Bearer " + auth.json()["access_token"]
	# print("Give the token for the authentification")


headers = {
	"method": "post",
	"content-type": "application/json",
	"Authorization": token_str
Ejemplo n.º 2
0
import requests
import json
import sys
import subprocess
import data

# authentification to api.swgoh.help
headers_auth = {
    "method": "post",
    "content-type": "application/x-www-form-urlencoded"
}
data_auth = data.get_swgoh_connection_data()

# sending request to obtain the token
auth = requests.post("https://api.swgoh.help/auth/signin",
                     data=data_auth,
                     headers=headers_auth)
token = auth.json()["access_token"]
token_str = "Bearer " + token
headers = {
    "method": "post",
    "content-type": "application/json",
    "Authorization": token_str
}
url_path = "https://api.swgoh.help/swgoh/"
ext = "guilds"
if len(sys.argv) > 1:
    payload = {"allycode": sys.argv[1], "languages": "fre_FR"}
else:
    print("Give an allycode of a member of the guild")