def process_random_org_query(pool_size): version = "" server = "https://api.random.org/json-rpc/1/invoke" + version endpoint_type = "" url = server + endpoint_type params = {} params["jsonrpc"] = "2.0" params["method"] = "generateIntegers" params["id"] = "1" params["params"] = { "n": 1, "min": 0, "max": pool_size, "replacement": false } random_json = dorequest(url, params, debug=_debug) random_json = json.loads(random_json) for each_item in random_json["result"]["random"]["data"]: chosen_number = int(each_item) return chosen_number
def get_content_profile(url_string): api_secret = "VOfAoG4HAc7RX4qlgXTsOvzWvV4eFtvJi19OPfZh" api_key = "g89dv60LlS0QPERttJiI4yht" # client_id = "" server = "http://api-sandbox.sociocast.com/" # server = "http://api.sociocast.com/" version = "1.0/" url = server + version + "content/profile" request_type = "GET" ### Options for content/profile # The URL for which the content's profile should be retrieved, passed # as a parameter above: url_string # By default, each classification category is represented in the profile by # its ID (a String). If you send true you will instead receive the # human-readable names. humread_bool = "1" future = datetime.datetime.now() epoch_ts = future.strftime("%s") message = "apikey=" + api_key + "&apisecret=" + api_secret + "&ts=" + \ epoch_ts SHA_sig = hashlib.sha256(message).hexdigest() response_dict = {} # Params will be encoded in the dorequest function params = { "url": url_string, "humread": humread_bool, "apikey": api_key, "ts": epoch_ts, "sig": SHA_sig } # Process the result from the search query, parse JSON # into a dictionary of results response_dict = dorequest(url, request_type, params) # Find the data list and paging dict in the response dictionary return response_dict