开发者

Redirection of xml file for iphone app

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 incom开发者_JAVA百科ings ;)

Gotye.


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.


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;
?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜