2014-10-19 53 views
0

PureBasic增加了一个JSON库,因此它可以很好地处理网页内容。但我不知道我从ReceiveHTTPFile()函数得到什么类型的输出。PureBasic中的ReceiveHTTPFile函数的输出在哪里?

他们的文档在这个主题上相当稀少。

这是我的代码。

Procedure GetBitminterData() 
FireUpNetwork = InitNetwork() 

Debug "If the number below is anything other than zero the network library is working." 
Debug FireUpNetwork 

URL$ = "https://bitminter.com/api/pool/stats/" 
FileName$ = "stats.json" 
BitMinterData = ReceiveHTTPFile(URL$, Filename$) ;THIS LINE HERE MEH 

Debug URL$ 
Debug BitMinterData 

; Read JSON data from a string 
; More importantly parse the bitminter stats.json file from above. 

Input$ = BitMinterData 
If ParseJSON(#JSON_Parse, Input$) 
    NewList Numbers() 
    ExtractJSONList(JSONValue(#JSON_Parse), Numbers()) 

    Debug "---------- Extracting values ----------" 
    Debug "" 
    ForEach Numbers() 
    Debug Numbers() 
    Next 
EndIf 

EndProcedure 
+0

[文档](http://www.purebasic.com/documentation/http/receivehttpfile.html)非常清楚。 “如果下载成功则返回非零值,否则返回零。”如果下载失败,则返回零;任何其他值意味着它的工作。哪一部分难以理解?你的代码尝试使用返回值作为输入('Input $ = BitMinterData'),这似乎表明你认为你得到的文件作为结果。您不是 - 该文件位于磁盘上,并具有您在'FileName $'中提供的文件名(也在同一文档链接的“参数”部分中对其进行了描述)。 – 2014-10-19 04:32:58

+0

在PureBASIC 5.40中,https是acepted。 – 2015-12-03 15:54:19

回答

0

问题是所有在purebasic中的http函数都不能处理“https”。我用最新的稳定的PureBasic 5.31测试了它。尝试任何与“http”的网址,它将工作。尝试“https”,它不会工作。

有一个purebasic的libcurl包装器(https://github.com/Progi1984/RWrappers/tree/master/LibCurl),但它已经5年了,它不再兼容purebasic 5.31。

如果您只需要“完成”,您仍然可以下载“curl”二进制文件(http://curl.haxx.se/download.html#Win32)并在purebasic应用程序中执行它。