how to use filter with python

Comments

3 comments

  • Avatar
    buildingdomain

    How to do it:

    def wooshmessage(request, message):

    #set here your settings
    PW_APP_CODE = ''
    PW_AUTH_API = ''
    PW_HWID_USER = ''
    PW_TOKEN_USER = ''
    
    
    pw_call('createMessage', {
        'auth': PW_AUTH_API,
        'application': PW_APP_CODE,
        'hwid' : PW_HWID_USER, 
        'notifications': [{
            'send_date': 'now',
             'content': 'overwinning',
                'data': {"custom": "json data"},
                'link': 'index.html',
                'ios_badges': '+1',
                'conditions': [['Username', 'EQ', 'john']]
            }
        ]
    }
    )
    

    response = render_to_response('core/template.html', { 'context': context }) return response

  • Avatar
    buildingdomain

    But before I use this, I make my own tag on pushwoosh.com. I name it "Username". You can register your new tag with this code in python:

    pw_call('setTags', {
        'application': PW_APP_CODE,
        'push_token': PW_TOKEN_SERAJA,
        'hwid' : PW_HWID_SERAJA,
        'tags': { 'Username' : 'john'}
    }
    )
    
  • Avatar
    buildingdomain

    I forget to write down the function pw_call:

    def pw_call(method, data): url = 'https://cp.pushwoosh.com/json/1.3/' + method data = json.dumps({'request': data}) req = Request(url, data.encode('UTF-8'), {'Content-Type': 'application/json'}) try: f = urlopen(req) response = f.read() f.close() print('Pushwoosh response: ' + str(response)) except Exception as e: print ('Request error: ' + str(e))

Please sign in to leave a comment.