Page 1 of 1

Internet UPC Database

Posted: Wed Jul 29, 2020 3:46 am
by Charles556
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

Re: Internet UPC Database

Posted: Wed Jul 29, 2020 7:10 am
by Kiffi
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 + ")"

Re: Internet UPC Database

Posted: Wed Jul 29, 2020 7:30 am
by infratec
I think you are totally wrong.
If you need XML-RPC, you have to write XML-RPC :wink:

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.

Re: Internet UPC Database

Posted: Wed Jul 29, 2020 4:13 pm
by Charles556
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.

Re: Internet UPC Database

Posted: Wed Jul 29, 2020 4:15 pm
by infratec
What is written in the response?

I have not a clear view in my crystal ball :wink:

Re: Internet UPC Database

Posted: Wed Jul 29, 2020 4:28 pm
by infratec
If I replace the methodName lookup with test, I get an answer.
So the request seems Ok.