Beispiel #1
0
def createEvent():
    data = request.get_json()
    return jsonify({
        "responseCode":
        eventApi.createEvent(data.get('name'), data.get('begin'),
                             data.get('end'), data.get('location'),
                             data.get('description'), data.get('leader'),
                             data.get('img'))
    })
Beispiel #2
0
def createEventTrigger():
    data = requests.get("http://gromdroid.nl/bslim/wp-json/wp/v2/events/" +
                        request.args.get("id")).json()
    print(data['event-venues'])
    address = requests.get(
        "http://gromdroid.nl/bslim/wp-json/wp/v2/event-venues/" +
        str(data['event-venues'][0])).json()
    soup = BSHTML(data["content"]["rendered"])
    images = soup.findAll('img')
    img = " "
    for image in images:
        img = image['src']
    apiKey = "MDQ4ZjNmYmMtYTMxMy00MzMzLWI3NWUtNTI0NWQ1MDdlYmZk"
    appId = "88a41eb2-1403-4aa9-8989-c0b430286788"
    header = {
        "Content-Type": "application/json; charset=utf-8",
        "Authorization": "Basic " + apiKey
    }

    payload = {
        "app_id": appId,
        "included_segments": ["All"],
        "contents": {
            "en": "Nieuw evenement van Bslim!"
        },
        "headings": {
            "en": data['title']['rendered']
        }
    }
    req = requests.post("https://onesignal.com/api/v1/notifications",
                        headers=header,
                        data=json.dumps(payload))
    return jsonify({
        "responseCode":
        eventApi.createEvent(request.args.get("id"), data["title"]["rendered"],
                             data["start"], data["end"], address['name'],
                             data["content"]["rendered"], data["author"], img)
    })
Beispiel #3
0
def createEventTrigger():
    data = requests.get("http://gromdroid.nl/bslim/wp-json/wp/v2/events/" +
                        request.args.get("id")).json()
    print(data)
    address = requests.get(
        "http://gromdroid.nl/bslim/wp-json/wp/v2/event-venues/" +
        str(data['event-venues'][0])).json()
    soup = BSHTML(data["content"]["rendered"])
    images = soup.findAll('img')
    img = " "
    for image in images:
        img = image['src']
    apiKey = "YTFkZGY1OGUtNGM5NC00ODdmLWJmN2QtNjMxYzNjMzk0MWJl"
    appId = "893db161-0c60-438b-af84-8520b89c6d93"
    header = {
        "Content-Type": "application/json; charset=utf-8",
        "Authorization": "Basic " + apiKey
    }

    payload = {
        "app_id": appId,
        "included_segments": ["All"],
        "contents": {
            "en": "Nieuw evenement van Bslim!"
        },
        "headings": {
            "en": data['title']['rendered']
        }
    }
    print("YAY")
    # req = requests.post("https://onesignal.com/api/v1/notifications", headers=header, data=json.dumps(payload))
    print(data["author"])
    return jsonify({
        "responseCode":
        eventApi.createEvent(request.args.get("id"), data["title"]["rendered"],
                             data["start"], data["end"], address['name'],
                             data["content"]["rendered"], data["author"], img)
    })