I just created an account on 500px.com, and would like to use their API: http://developer.500px.com/
But it looks like it cant return JSONP, only JSON.
Is there any way to make a php file that you can post a url to -> make it convert the response from the api from JSON to JSONP, so i can handle it on the client side?
I havent been writing any PHP in a long time, so any help is appreciated. Hope you get the idea, otherwise ill elaborate. Thanks
Sure you can. The only difference between JSON and JSONP is that JSONP is wrapped with a function name;
In it’s simplest form you can end up with something like this;
and you’d expect clients to use it like this;
Note the encoded URL and the addition of the callback parameter to know which function to invoke.
Of course, you’ll need to valid the input; check the existance of the parameters, check the
endpointpassed isn’t malicious etc. You might want to also cache the responses on your server to stop you reaching any limits imposed on the API.Something more resilient against malicious input could look like;