How to use external JSON ...?

spent several hours trying to figure it out, but cannot let my life determine what is going wrong.

All I'm trying to do is download this:

https://recruit.zoho.com/ats/EmbedResult.hr?jodigest=2cV.Sr2As6VxhLMxQGuTNij*g.Fb3J7ysduDs.AC9sU-&atslocale=en_GB&rawdata=json 

which I consider json in javascript / jquery or php and use the data.

I looked through jsonp, followed some tutorials, used some demos as templates, and just couldn't get this data to work.

If someone can shed some light, he will be very grateful. It really should not be so difficult, but I do not know what will be wrong.

+2
source share
3 answers

Yes, this is JSON. The site may not support JSONP, so you will need to use PHP to do this.

This is not tested, but should work.

 <?php $url = 'https://recruit.zoho.com/ats/EmbedResult.hr?jodigest=2cV.Sr2As6VxhLMxQGuTNij*g.Fb3J7ysduDs.AC9sU-&atslocale=en_GB&rawdata=json'; $JSON = file_get_contents($url); // echo the JSON (you can echo this to JavaScript to use it there) echo $JSON; // You can decode it to process it in PHP $data = json_decode($JSON); var_dump($data); ?> 
+6
source

JSONP relies on the server to return a formatted JSONP response . In principle, to use JSONP, the server should return a JSON string wrapped in a function call ( {"foo":1} becomes func({"foo":1}) ).

Since the server you are using does not return a JSONP response, you cannot use JSONP, you can use JSON.

This is a shame because JSON cannot be used with x-domain due to the same origin policy (SOP) . Thus, the only option you have is to use a proxy server that retrieves JSON from the server and passes it to you in JSONP (see Yahoo Pipes ) or which is on the same domain as the requested page (write a simple PHP script to get the file using file_get_contents() and then echo output), in which case it can return JSON.

+5
source

I briefly reviewed the requirements and it looks like you need an API key as well as an account. I saw that the site provides services only for XML and JSON. It looks pretty well documented.

0
source

All Articles