Just starting out? Need help? Post your questions and find answers here.
Charles556
New User
Posts: 3 Joined: Thu Jul 10, 2008 12:29 am
Location: USA
Post
by Charles556 » Wed Jul 29, 2020 3:46 am
Has anybody used this website (Internet UPC Database) to get information for upc code? all i got is redirected and then a timeout. Would post code but I tweaked it so much it don't do that anymore.
Found a snippet of code that did the redirect. Did take out my key.
Code: Select all
rpc_key.s = "*******************"
;#CRLF= Chr(13) + Chr(10)
Define xml.s
upc= 05225318
params.s ="{"+"'"+"rpc_key"+","+rpc_key+","+"upc"+"'"+"}"
AllData.s = "s.lookup(params)"
; --- Example:
XIncludeFile "c:/PB Programs/HTTPGET.pbi"
If InitNetwork() = 0
Debug "No TCP provider..."
Else
Status.l = HTTP_GET("http://www.upcdatabase.com/xmlrpc", AllData)
Debug "DownloadFile returned: " + Str(Status)
EndIf
Kiffi
Addict
Posts: 1520 Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9
Post
by Kiffi » Wed Jul 29, 2020 7:10 am
Charles556 wrote: Code: Select all
params.s ="{"+"'"+"rpc_key"+","+rpc_key+","+"upc"+"'"+"}"
AllData.s = "s.lookup(params)"
untested, but this looks better:
Code: Select all
params.s ="{"+"'"+"rpc_key"+","+rpc_key+","+"upc"+"'"+"}"
AllData.s = "s.lookup(" + params + ")"
Hygge
infratec
Always Here
Posts: 7785 Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany
Post
by infratec » Wed Jul 29, 2020 7:30 am
I think you are totally wrong.
If you need XML-RPC, you have to write XML-RPC
Try this:
Code: Select all
EnableExplicit
Define xml$, rpc_key$, upc$, params$, Request.i
rpc_key$ = "*******************"
upc$ = "0688339923094"
params$ = ~"<?xml version=\"1.0\"?>" + #CRLF$
params$ + ~"<methodCall>" + #CRLF$
params$ + ~" <methodName>lookup</methodName>" + #CRLF$
params$ + ~" <params>" + #CRLF$
params$ + ~" <param>" + #CRLF$
params$ + ~" <value>" + #CRLF$
params$ + ~" <struct>" + #CRLF$
params$ + ~" <member>" + #CRLF$
params$ + ~" <name>rpc_key</name>" + #CRLF$
params$ + ~" <value><string>" + rpc_key$ + "</string></value>" + #CRLF$
params$ + ~" </member>" + #CRLF$
params$ + ~" <member>" + #CRLF$
params$ + ~" <name>upc</name>" + #CRLF$
params$ + ~" <value><string>" + upc$ + "</string></value>" + #CRLF$
params$ + ~" </member>" + #CRLF$
params$ + ~" </struct>" + #CRLF$
params$ + ~" </value>" + #CRLF$
params$ + ~" </param>" + #CRLF$
params$ + ~" </params>" + #CRLF$
params$ + ~"</methodCall>"
Debug params$
Debug "---------------"
If InitNetwork()
Request = HTTPRequest(#PB_HTTP_Post, "https://www.upcdatabase.com/xmlrpc", params$)
If Request
Debug HTTPInfo(Request, #PB_HTTP_StatusCode)
Debug "---------------"
Debug HTTPInfo(Request, #PB_HTTP_Response)
FinishHTTP(Request)
EndIf
EndIf
Btw.: it is no needed to call an online service, I think here are some examples for creating such stuff in PB.
Last edited by
infratec on Wed Jul 29, 2020 4:35 pm, edited 1 time in total.
Charles556
New User
Posts: 3 Joined: Thu Jul 10, 2008 12:29 am
Location: USA
Post
by Charles556 » Wed Jul 29, 2020 4:13 pm
Thanks for the replies, still not working. the website (
https://www.upcdatabase.com/ ) takes a upc code and returns the information for that one upc code. It has several different formats it use to return that information. XML-RPC is the web service used to look up the upc code and return the information. Hope this help.
infratec
Always Here
Posts: 7785 Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany
Post
by infratec » Wed Jul 29, 2020 4:15 pm
What is written in the response?
I have not a clear view in my crystal ball
infratec
Always Here
Posts: 7785 Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany
Post
by infratec » Wed Jul 29, 2020 4:28 pm
If I replace the methodName lookup with test , I get an answer.
So the request seems Ok.