python example 1:

import requests
def basic_auth_example(network_name,api_key,offer_s,update_data):
    api_url = "http://%s:%s@%s.api.offerslook.com/v1/offers/%s" %(network_name,api_key,network_name,offer_s)
    data = update_data 
    querystring = ''
    req = requests.request("PUT",api_url,data=update_data,headers={'content-type':"application/json",'cache-control': "no-cache",'postman-token': "4d5c83b4-a338-19a5-03d0-d5a81524bfac"},params=querystring)
    response = req.text
    print response

offer_id = 10001
network_name = "demo"
api_key = "8cca20a07a24a7e425835221def4066a"
update_data = '{"offer":{"lead_traffic":1}}'    #Enable offer sync click
basic_auth_example(network_name,api_key,offer_id,update_data)

python example 2:

import base64,json,urllib2
def basic_auth_example2(network_name,api_key,offer_s,update_data):
    api_url = "http://%s.api.offerslook.com/v1/offers/%s" %(network_name,offer_s)
    base64string = base64.encodestring('%s:%s' %(network_name,api_key))[:-1]
    authheader =  "Basic %s" %base64string
    req = urllib2.Request(api_url,data=update_data,headers={'content-type':'application/json','Authorization':authheader});
    req.get_method = lambda:'PUT';
    response = urllib2.urlopen(req);
    print response.read();

offer_id = 10001
network_name = "demo"
apikey = "8cca20a07a24a7e425835221def4066a"
dict_data = {"offer": {"lead_traffic": 1}};
data = json.dumps(dict_data);
basic_auth_example2(network_name,apikey,offer_id,data)

results matching ""

    No results matching ""