Your Digital Media Has Never Looked So Good

 
balbant
Topic Author
Posts: 30
Joined: Fri Jun 03, 2016 12:45 am
Location: India

How can pass roAssociativeArray in URL parameters?

Tue Sep 03, 2019 5:39 am

Hi,
Can we request URL with roAssociativeArray parameters? as below :-

GetFunction(http://mydomain.com/webservices/webservices.php?route=option&custom_option=[{"option_id" : "7", "option_value" : 24}, {"option_id" : "8", "option_value" : 27}])


or
options = [{"option_id" : "7", "option_value" : 24}, {"option_id" : "8", "option_value" : 27}]

GetFunction("http://mydomain.com/webservices/webservices.php?route=option&custom_option"+options)


I have requested above URLs but I am getting error, my code is-
function GetFunction(url)
        request = CreateObject("roUrlTransfer")
        request.SetCertificatesFile("common:/certs/ca-bundle.crt")
        request.AddHeader("X-Roku-Reserved-Dev-Id", "")
        request.InitClientCertificates()
        request.enablehostverification(false)
        request.enablepeerverification(false)
        request.AddHeader("Content-Type", "application/json")
        request.SetUrl(url)  
        port = CreateObject("roMessagePort")
        request.SetMessagePort(port)
        request.SetPort(port)    
        timer = createobject("roTimeSpan")
        timer.Mark()
        request.AsyncGetToString()
        while true
            msg = wait(0, port)
            if type(msg) = "roUrlEvent" then
                return "OK"
                exit while
            end if       
        end while
end function

Please advice. How to reuqest thes type of URLs in RokuSG?
 
User avatar
squirreltown
Posts: 870
Joined: Sun Apr 21, 2013 2:20 pm

Re: How can pass roAssociativeArray in URL parameters?

Tue Sep 03, 2019 6:36 am

GetFunction("http://mydomain.com/webservices/webservices.php?route=option&custom_option="+"[{'option_id' : '7', 'option_value': 24}]")



Obviously I can't test it but this doesn't throw a syntax error like yours did.
Kinetics Screensavers

Who is online

Users browsing this forum: No registered users and 4 guests