ut = CreateObject("roURLTransfer")
ut.SetPort(CreateObject("roMessagePort"))
myname = FormatJson(name)
myposter= FormatJson(hdposterUrl)
mystream= FormatJson(stream)
mygid= FormatJson(gid)
mynameJsonEscaped = ut.Escape(myname)
myposterJsonEscaped= ut.Escape(myposter)
mystreamJsonEscaped= ut.Escape(mystream)
mygidJsonEscaped= ut.Escape(mygid)
url="http://xxx.xxx.x.xxx:8000/Favorite/myCreate.php?filename="+myfile + "&channel=" + mynameJsonEscaped + "&hdposterUrl=" + myposterJsonEscaped + "&stream=" + mystreamJsonEscaped + "&gid=" + mygidJsonEscaped
If ut.AsyncPostFromString(url) Then
event=wait(timeout, ut.GetPort())
if type(event)= "roUrlEvent"
print event.GetResponseCode()
if event.GetResponseCode()= 200
result=event.PostFromString(url)
?result
m.urlCode=event.GetResponseCode()
m.failure=event.GetFailureReason()
return m.urlCode
else
m.urlCode=event.GetResponseCode()
?"FAILURE CODE "m.urlCode
return result
end if
elseif event = invalid
ut.AsyncCancel()
endif
end if
"destruk" wrote:
As your get request works, and the post request doesn't, for your server-side script you'll want to decode the json being sent through the POST method -
$input=@file_get_contents("php://input");
$event_json=json_decode($input,true);
"destruk" wrote:
Your url you are using is acting as a GET request, not a POST request.
With a GET request the data goes appended to the url string like you have it.
With a POST request the data is sent in the request BODY itself - the url is just the basic url without any variables strung along in the url.
"destruk" wrote:
Just because you can doesn't mean you should -- if a get request string url is too long your server will lose data on the request. Apache will experience problems if your url length is longer than 4000 characters. Post data is limited to 8 megabytes by default.
"destruk" wrote:
I just find it easier to code for without mixing and matching request types. Appending get variables to a post means you need to handle both on the other end - and definitely doubling them up sending the same variables both ways in the same request is inefficient.
url="http://xxx.xxx.x.xxx:8000/Favorite/myCreate.php?filename="+myfile + "&channel=" + mynameJsonEscaped + "&hdposterUrl=" + myposterJsonEscaped + "&stream=" + mystreamJsonEscaped + "&gid=" + mygidJsonEscaped
We’re upgrading Roku Community to bring you a faster, more mobile-friendly experience. You may notice limited functionality or read-only access during this time. Read more here.
Planned Downtime:
Community will be unavailable for up to 24–48 hours during the upgrade window during the week of May 19th and you may notice reduced functionality.
In the meantime, for additional assistance, visit our Support Site.
We're sorry for this disruption — we’re excited to share what’s next!