Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

troubles communicating with an API

Explorer ,
Oct 28, 2011 Oct 28, 2011

hi,

any one in here wouldn't know how to parse cfhttp results like:

[RESPONSE]

PROPERTY[TOTAL][0]=15

PROPERTY[FIRST][0]=0

PROPERTY[DOMAIN][0]=somedomain.org

PROPERTY[DOMAIN][1]=someotherdomain.be

PROPERTY[DOMAIN][2]=yetanotherdomain.com

........

PROPERTY[DOMAIN][14]=andanotherone.be

PROPERTY[COUNT][0]=15

PROPERTY[LAST][0]=14

PROPERTY[LIMIT][0]=10000

DESCRIPTION=Command completed successfully

CODE=200

QUEUETIME=0

RUNTIME=0.036

EOF

or has a clue how to write a script to work with hexonet ?

704
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Oct 28, 2011 Oct 28, 2011

Its sort of hacky, but you could use regular expressions to convert the data into a multi-delimited format to be able to parse with CF.  something like this:

<cfset sDelimFormat = ReReplaceNoCase(CFHTTP.FileContent, "PROPERTY\[([^\]]+)\]\[([0-9]+)]=([^\n]*)", "\1,\2=\3", "all")>

You'll get something like this:

TOTAL,0=15
FIRST,0=0
DOMAIN,0=somedomain.org
DOMAIN,1=someotherdomain.be
DOMAIN,2=yetanotherdomain.com
DOMAIN,14=andanotherone.be
COUNT,0=15
LAST,0=14
LIMIT,0=10000
DESCRIPTION=Command completed successfully
CODE=200

Although I'm sure the regex deities hanging around the board could probably work out some magic pattern to convert the format into JSON, which would be really slick.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 29, 2011 Oct 29, 2011
LATEST

it's indeed sort of hacky... i have a few other connection possibilities, but don't have a clue how to start with those... cfr:

http://www.hexonet.net/epp1.php

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources