views:

18

answers:

2

Hey guys,

I have a xml file on my server like the one below :

www.myWebSite.com/myXmlFile.xml

which is used by my iphone application.

In case the address of my xml file changes to

www.myOtherWebsite.com/myXmlFile.xml

How can I make my app to work anyway ? What kind of PHP server-side code do I need to write ? Is NSURLConnection supporting reirections ?

Thanks for any incomings ;)

Gotye.

A: 

One option would be use PHP-CURL to write a PHP script that will reside in:

www.myWebSite.com/myXmlFile.xml

And will open a HTTP connection (with CURL) to:

www.myOtherWebsite.com/myXmlFile.xml

It's pretty straightforward and there are a lot of examples on how to do this.

Pablo Santa Cruz
A: 

Yes, NSURLConnection will support redirects at the HTTP level. It will do redirects by default; you can also control whether or not to allow the redirect from the NSURLConnection delegate.

See URL Loading System: Handling Redirects and Other Request Changes

On the server side, you can send a redirect from PHP like:

<?php
header("Location: http://www.myOtherWebsite.com/myXmlFile.xml");
exit;
?>
David Gelhar
And as long as my file is still on www.myWebSite.com, can I do <?phpheader("Location: http://www.myWebsite.com/myXmlFile.xml");exit;?>or is it a bad move to do a redirection if I can avoid it ?
gotye