Sending Onesignal/gamethrive push by JSON network request -
i trying send json request send push notification using following code error message network response saying "app_id not found". using corona shouldnt matter long json format right.
local json = require "json" local function networklistener( event ) if ( event.iserror ) print( "network error!" ) else print ( "response: " .. event.response ) end end headers = {} headers["app_id"] = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaa" headers["authorization"] = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbb" headers["content-type"] = "application/json" local params = {} commands_json = { ["contents"] = "english message" } postdata = json.encode(commands_json) local params = {} params.header = headers params.body = postdata network.request( "https://onesignal.com/api/v1/notifications","post",networklistener,params)
i work out.
function sendjson(url, action, in_json, callback) local json = require ( "json" ) local headers = {} headers["content-type"] = "application/json" headers["accept-language"] = "en-us" headers["authorization"] = "basic 12121321313123" -- put rest api local params = {} params.headers = headers params.body = json.encode( in_json ) network.request ( url, action, callback, params ) end local function networklistener( event ) if ( event.iserror ) print( "network error!") else print ( "response: " .. event.response ) end end local jsontosend = {["app_id"] = "aaaaaa-222-222-33-3333333333", --put yours app id ["contents"] = {["en"] = "george challenged beat score!"}, ["included_segments"] = "all", ["isandroid"] = true, ["isios"] = true,} --["include_player_ids"] = ["(recipient_player_id_here)"]} sendjson("https://gamethrive.com/api/v1/notifications", "post", jsontosend, networklistener)
Comments
Post a Comment