xml – 如何在roku中向某个服务器发出api请求
发布时间:2020-12-16 23:06:22 所属栏目:百科 来源:网络整理
导读:我非常擅长使用 roku和roku特定语言(BasicScript).我需要对某些服务器进行api调用以获取通道.我不知道如何在roku中这样做.请建议. 解决方法 这是直接的方法,而不必依赖SDK中包含的代码库的语法: 阻止方法(所有程序执行都会停止,直到检索到URL): url="http:
我非常擅长使用
roku和roku特定语言(BasicScript).我需要对某些服务器进行api调用以获取通道.我不知道如何在roku中这样做.请建议.
解决方法
这是直接的方法,而不必依赖SDK中包含的代码库的语法:
阻止方法(所有程序执行都会停止,直到检索到URL): url="http://myserver.com/anExampleQuery?getmydata&apikey=AX5GZP5LL45D987D0&format=XML" xfer=createobject("roURLTransfer") xfer.seturl(url) data=xfer.gettostring() 非阻塞方法,您可以在等待数据时执行其他操作: url="http://myserver.com/anExampleQuery?getmydata&apikey=AX5GZP5LL45D987D0&format=XML" xfer=createobject("roURLTransfer") xfer.seturl(url) port=createobject("roMessagePort") xfer.setport(port) timer=createobject("roTimeSpan") timer.mark() xfer.asyncgettostring() while true msg=wait(100,port) '100 millisecond pause if type(msg)="roUrlEvent" then if msg.getresponsecode()=200 then data=msg.getstring() headers=msg.getresponseheadersarray() exit while else xfer.asynccancel() end if else print "do something useful while we wait for data" end if if timer.totalmilliseconds() > 500 then ?"timeout exceeded" exit while end if end while print "***************HEADERS******************" for each header in headers print header end for print "***************DATA*********************" print data print "****************************************" (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容