python - Not Ready: File Not Uploaded when adding to Facebook Custom Audience -
python - Not Ready: File Not Uploaded when adding to Facebook Custom Audience -
i attempting add together users facebook custom audience using version 2.1 of api.
i'm using python script create new audience, , add together users it.
import json, requests # set params account_id = 'an ads business relationship id' audience_name = 'a new name' token = 'a valid access token' # create new audience id posterity url = "https://graph.facebook.com/act_" + account_id + "/customaudiences" response = requests.post(url, {"name": audience_name, "access_token": token}) resp_dict = json.loads(response.content) audience_id = resp_dict["id"] # output new audience name , id print("for audience name of:", audience_name) print("created audience id of:", audience_id) # add together email addresses audience the_file = open("the.payload", "r") payload = the_file.read() the_file.close() url = 'https://graph.facebook.com/v2.1/' + audience_id + '/users' params = {"access_token": token, "payload": payload} response = requests.post(url, params=params) # output results print("response status code:", response.status_code) print("response content:", response.content) a sample of contents of "the.payload" is:
{"data":["a8649fb702fb0a67e21ed5120a589cf4d15dd59e2eebb1ad606485731b124100","4842b7883df3c9048abbff1fddb3fd634bed474450f8b2b9102c4bf76fc33381"],"schema":"email_sha256"} except, in file, instead of having 2 valid email addresses have been formatted sha256, , written per hex, per docs, have 1100 of them.
when run script, receive:
('for audience name of:', 'the name gave') ('created audience id of:', u'a valid id number') ('response status code:', 200) ('response content:', '{"audience_id":"a valid id number","num_received":1100,"num_invalid_entries":0,"invalid_entry_samples":[]}') however, more hr later, "not ready, file not uploaded" shows in ui 100% of uploads done using method.
can tell me how right code add together users custom audiences successfully? i've reviewed facebook's docs extensively, believe i'm next format.
thank in advance!
this turned out issue hashing algorithm.
after posting this, received re-create of email hashing algorithm proven work. this:
import hashlib email = "somebody@somewhere.com" email = email.strip().lower() email = hashlib.sha256(email).hexdigest() i compared hash produced here own hash, , wasn't coming out same. after correcting stripping whitespace , not reusing hasher in loop, problem resolved.
so, not ready can result hashing issue behind scenes, or upload containing few valid & matching email addresses.
python facebook facebook-ads-api
Comments
Post a Comment