Page 1 of 1

hb_jsonDecode() this Website

Posted: Sun Mar 19, 2023 3:52 am
by AUGE_OHR
hi,

i try to use hb_jsonDecode() for "this" Website but i got NIL ...

---

my old working Way

Code: Select all

   oHttp:Open( "GET", cUrl, .F. )  // https://www.hmgforum.com/viewtopic.php?t=7403
   oHttp:setRequestHeader( "User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0" )

   oHttp:Send()

   IF nStatus = 200
      StrFile( oHttp:ResponseBody(), cFile )
this way i got Website from "cURL" as "cFile" in HTML Format which i try to "analyze" to get Information

...

1st Try :

Code: Select all

PROCEDURE TestJSON()
LOCAL cFile, cMemo, aReturn,ii,nMax,aArray

   cFile := "d:\PHPFORUM\HMG\T0007403.HTML"
   cMemo := MEMOREAD(cFile)
   aReturn := hb_jsonDecode(cMemo, @aArray )
altd()
RETURN
i try to use cFile which i have download above
but aReturn is NIL and aArray is Empty ...

what i´m doing wrong :?:

---

i try to change oHttp:setRequestHeader() to

Code: Select all

   oHttp:setRequestHeader( "Content-Type", "text/xml; charset=utf-8")
and try

Code: Select all

   * x1 := hb_jsonDecode( oHttp:responseText, @aArray )
   x1 := hb_jsonDecode( oHttp:ResponseBody(), @aArray )
   altd()
but still Result x1 is NIL and aArray is Empty ...

---

can somebody show me how use use hb_jsonDecode() for "this" Website :?:
need some help please

Re: hb_jsonDecode() this Website

Posted: Sun Mar 19, 2023 2:20 pm
by Rathinagiri
Hi, can you give the content received in cFile? Only if it is in JSON format using {} and [] you can decode.

Re: hb_jsonDecode() this Website

Posted: Mon Mar 20, 2023 12:31 am
by AUGE_OHR
hi Rathi,

it was a Answer from ChatGPT when ask how to get Content of Website
it sound good so i try it "here" in this Forum

but Website "generate" by phpBB Forum Software seems not to use JSON Format

Re: hb_jsonDecode() this Website

Posted: Tue Mar 21, 2023 3:42 am
by Rathinagiri
Yes. For getting JSON format, we need an API. There are PHPBB APIs to generate JSON for older versions of forum. Since we have updated to the latest version, it may take sometime to upgrade/update the API by the developer. Once updated, we can try to install the API.

Re: hb_jsonDecode() this Website

Posted: Tue Mar 21, 2023 5:10 am
by AUGE_OHR
hi Rathi,

it would be great when Forum can generate JSON "Output"
it would give us a Chance to "use" JSON and to "learn" was is need