I have this code so far I is working but to check if there is the code in the mysql comes channel how can I do that if it exists you can enjoy the canal
regScreen
function GetLinkingCode()
result = invalid
xfer = CreateObject("roURLTransfer")
xfer.SetURL("http://www.example.com/pin.php")
response = xfer.GetToString()
xml = CreateObject("roXMLElement")
if xml.Parse(response)
result = {
code: xml.linkingCode.GetText()
expires: StrToI(xml.linkingCode@expires)
}
end if
return result
end function
function ValidateLinkingCode(linkingCode)
result = false
xfer = CreateObject("roURLTransfer")
xfer.SetURL("http://www.example.com/validate.php?code=" + linkingCode)
response = xfer.GetToString()
xml = CreateObject("roXMLElement")
if xml.Parse(response)
if UCase(xml.status.GetText()) = "SUCCESS"
sec = CreateObject("roRegistrySection", "mySection")
sec.Write("deviceToken", xml.deviceToken.GetText())
sec.Flush()
showCongratulationsScreen()
result = true
end if
end if
return result
end function
'******************************************************
'Show congratulations screen
'******************************************************
Sub showCongratulationsScreen()
port = CreateObject("roMessagePort")
screen = CreateObject("roParagraphScreen")
screen.SetMessagePort(port)
screen.AddHeaderText("Congratulations!")
screen.AddParagraph("You have successfully linked your Roku player to your account")
screen.AddParagraph("Select 'start' to begin.")
screen.AddButton(1, "start")
screen.Show()
while true
msg = wait(0, screen.GetMessagePort())
if type(msg) = "roParagraphScreenEvent"
if msg.isScreenClosed()
print "Screen closed"
exit while
else if msg.isButtonPressed()
print "Button pressed: "; msg.GetIndex(); " " msg.GetData()
exit while
else
print "Unknown event: "; msg.GetType(); " msg: "; msg.GetMessage()
exit while
endif
endif
end while
End Sub
sub ShowLinkScreen()
dt = CreateObject("roDateTime")
' create a roCodeRegistrationScreen and assign it a roMessagePort
port = CreateObject("roMessagePort")
screen = CreateObject("roCodeRegistrationScreen")
screen.SetMessagePort(port)
' add some header text
screen.AddHeaderText("Link Your Account")
' add some buttons
screen.AddButton(1, "Get new code")
screen.AddButton(2, "Back")
' Add a short narrative explaining what this screen is
screen.AddParagraph("Before you can use this channel, you must link the channel to your account.")
' Focal text should give specific instructions to the user
screen.AddFocalText("Go to http://www.example.com/roku, log into your account, and enter the following code.", "spacing-normal")
' display a retrieving message until we get a linking code
screen.AddFocalText("Activation Code", "spacing-dense")
screen.SetRegistrationCode("Retrieving...")
screen.Show()
' get a new code
linkingCode = GetLinkingCode()
if linkingCode <> invalid
screen.SetRegistrationCode(linkingCode.code)
else
screen.SetRegistrationCode("Failed to get code...")
end if
screen.Show()
while true
' we want to poll the API every 15 seconds for validation,
' so set a 15000 millisecond timeout on the Wait()
msg = Wait(15000, screen.GetMessagePort())
if msg = invalid
' poll the API for validation
if ValidateLinkingCode(linkingCode.code)
' if validation succeeded, close the screen
exit while
end if
dt.Mark()
if dt.AsSeconds() > linkingCode.expires
' the code expired. display a message, then get a new one
d = CreateObject("roMessageDialog")
dPort = CreateObject("roMessagePort")
d.SetMessagePort(dPort)
d.SetTitle("Code Expired")
d.SetText("This code has expired. Press OK to get a new one")
d.AddButton(1, "OK")
d.Show()
Wait(0, dPort)
d.Close()
screen.SetRegistrationCode("Retrieving...")
screen.Show()
linkingCode = GetLinkingCode()
if linkingCode <> invalid
screen.SetRegistrationCode(linkingCode.code)
else
screen.SetRegistrationCode("Failed to get code...")
end if
screen.Show()
end if
else if type(msg) = "roCodeRegistrationScreenEvent"
if msg.isScreenClosed()
exit while
else if msg.isButtonPressed()
if msg.GetIndex() = 1
' the user wants a new code
code = GetLinkingCode()
linkingCode = GetLinkingCode()
if linkingCode <> invalid
screen.SetRegistrationCode(linkingCode.code)
else
screen.SetRegistrationCode("Failed to get code...")
end if
screen.Show()
else if msg.GetIndex() = 2
' the user wants to close the screen
exit while
end if
end if
end if
end while
screen.Close()
end sub
that I'm doing wrong
Our system http://www.rokumanager.com