[英]API response JSON waiting for the final result
I'm new here and new to JavaScript programming in Android Studio too. 我是这里的新手,也是Android Studio中JavaScript编程的新手。 I'm working on a app that uses the API called page2images that gives back the screenshot of a website by searching a URL. 我正在开发一个使用名为page2images的API的应用程序,该API通过搜索URL来返回网站的屏幕截图。 The response is a JSON code, but when I make a call I see something like this: 响应是一个JSON代码,但是当我打电话时,我看到的是这样的:
{"status":"processing","estimated_need_time":50}
after a while it shows me this: 一段时间后,它向我显示:
{"status":"finished","image_url":"http://api.page2images.com/ccimages/fd/fb/jDgCCNYu2kyKwKDs.png","duration":1,"left_calls":"2910","mobileok":"yes","ori_url":"http:\/\/www.twitter.com"}
that's what I need.. but how can I make the program wait till the second code is showed? 那就是我需要的..但是如何让程序等到第二个代码显示出来呢? the URL is the same and if I refresh the page I can see the estimated_need_time
decreasing but if I do the parsing of image_url
I would have to wait the right response but when I click the button the app would have to do all by its own.. URL是相同的,如果刷新页面,我可以看到estimated_need_time
减少,但如果解析image_url
,则必须等待正确的响应,但是当我单击按钮时,应用程序必须自己完成所有操作。 。
I'm not sure I correctly see your problem, but If I do just wait "estimated_need_time" and call the api again. 我不确定我是否正确地看到了您的问题,但是如果我这样做,请等待“ estimated_need_time”,然后再次调用该api。 Parse the first answer, set for example a handler to wait responded amount of seconds and call the api again. 解析第一个答案,例如将处理程序设置为等待响应的秒数,然后再次调用api。 It should solve your problem. 它应该可以解决您的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.