Proxy for API call? Why?

Hello I’m reading the Sitepoint book PHP Master Cutting Edge Code. I’m currently reading about web services and they’re talking about using web proxies. Before I begin let me say that I understand the issues surrounding cross domain policies, what that means to browsers and why they limit the browsers etc. I also get what (at least in broad strokes) a proxy server is.

Here’s what’s not clear to me. Why do I need to setup a proxy script on my domain to access another third party service? For example if I want to connect to Flicker’s API I don’t have to create a proxy, I simply use xml-RPC calls and can connect to Flickr and get a response back. So why would I need a proxy?

Is a proxy used in cases where the third party site is not setup to receive calls from external websites? The book explains how to setup a proxy script on my local site, I’m just unsure why I need to do this.

Thanks! :slight_smile:

It’s not talking about proxy servers but a proxy script, i.e., a script that request something from another server and then without modifying any of it send it back to the browser. It’s needed for javascript to make a request to another domain (unless the service also supports JSONP in which case you can use that, but that’s a whole other story).
Of course using PHP you don’t have the restrictions that browsers have so there you don’t need to use proxy scripts but can just access the resource directly.

I think I just had a forehead slap kind of moment and forgot the book was speaking about ajax calls in that chapter. (Too focused on the service details). Thanks for clarifying!