| Line 105... |
Line 105... |
| 105 |
|
105 |
|
| 106 |
pushpostrequest = urllib2.Request('http://api.profittill.com/pushnotifications/generateAffiliateUrl', encoded_url_params, headers=aff_url_headers)
|
106 |
pushpostrequest = urllib2.Request('http://api.profittill.com/pushnotifications/generateAffiliateUrl', encoded_url_params, headers=aff_url_headers)
|
| 107 |
pushpostrequest.add_header("Authorization", "Basic %s" % DTR_API_BASIC_AUTH)
|
107 |
pushpostrequest.add_header("Authorization", "Basic %s" % DTR_API_BASIC_AUTH)
|
| 108 |
json_result = json.loads(urllib2.urlopen(pushpostrequest).read())
|
108 |
json_result = json.loads(urllib2.urlopen(pushpostrequest).read())
|
| 109 |
notificationRecord.url = json_result['url']
|
109 |
notificationRecord.url = json_result['url']
|
| - |
|
110 |
logging.debug('User Id:-'+str(notificationRecord.userId)+' Notification Url:- '+ str(notificationRecord.url))
|
| 110 |
|
111 |
|
| 111 |
data = {"message":notificationRecord.message,"cid":notificationRecord.campaignId,"title":notificationRecord.title,
|
112 |
data = {"message":notificationRecord.message,"cid":notificationRecord.campaignId,"title":notificationRecord.title,
|
| 112 |
"type":notificationRecord.type,"url":notificationRecord.url,"vibrate":1,"sound":1,"largeIcon":"large_icon",
|
113 |
"type":notificationRecord.type,"url":notificationRecord.url,"vibrate":1,"sound":1,"largeIcon":"large_icon",
|
| 113 |
"smallIcon":"small_icon"}
|
114 |
"smallIcon":"small_icon"}
|
| 114 |
|
115 |
|
| Line 118... |
Line 119... |
| 118 |
regIds = []
|
119 |
regIds = []
|
| 119 |
regIds.append(notificationRecord.gcmRegId)
|
120 |
regIds.append(notificationRecord.gcmRegId)
|
| 120 |
post_data['registration_ids'] = regIds
|
121 |
post_data['registration_ids'] = regIds
|
| 121 |
|
122 |
|
| 122 |
post_data_json = json.dumps(post_data)
|
123 |
post_data_json = json.dumps(post_data)
|
| 123 |
logging.debug('Post Data Json :-'+str(post_data_json))
|
124 |
logging.debug('User Id:- '+str(notificationRecord.userId)+' Post Data Json :- '+str(post_data_json))
|
| 124 |
|
125 |
|
| 125 |
response = requests.post(GCM_URL, data=post_data_json, headers=headers)
|
126 |
response = requests.post(GCM_URL, data=post_data_json, headers=headers)
|
| 126 |
logging.debug('Response :-'+str(response.text))
|
127 |
logging.debug('User Id:- '+str(notificationRecord.userId)+' Response :-'+str(response.text))
|
| 127 |
result = json.loads(response.text)
|
128 |
result = json.loads(response.text)
|
| 128 |
pushnotification = Pushnotifications.get_by(id=notificationRecord.pushNotificationId)
|
129 |
pushnotification = Pushnotifications.get_by(id=notificationRecord.pushNotificationId)
|
| 129 |
|
130 |
|
| 130 |
if result["success"]:
|
131 |
if result["success"]:
|
| 131 |
pushnotification.type = "sent"
|
132 |
pushnotification.type = "sent"
|