Reputation: 318
I am building a contact backup application for iphone.I have uploaded address-book contacts to a http server using POST method as a plist file.Now i want to retrieve these contacts from server and load them to the address book. Now i want to know how can i get these data from server?May be i could use GET request.But i don't know how to perform it.
I have used the following php code for server where i am uploading data.
<?php
$target = "./upload/";
print_r($_FILES);
$target = $target . basename( $_FILES['uploaded']['name']) ;
$ok=1;
if(is_uploaded_file($_FILES['uploaded']['tmp_name']))
{
move_uploaded_file($_FILES['uploaded']['tmp_name'], $target);
echo "YES";
}
else
{
echo "Not uploaded";
}
?>
Now i have to write a method in application which can retrieve information from server.And also what php code i need to support retrieving data from server?
Please share some information with me if you know anything about these topics.
Thanks.
Upvotes: 1
Views: 265
Reputation: 11
If building an iphone app I recommend using http://allseeing-i.com/ASIHTTPRequest/How-to-use how you format the data is up to you. you could send the whole plist file or make it into another format before transmission
Upvotes: 1
Reputation: 45180
Maybe simple echo
will help?
<?php
header('Content-Type: text/xml');
echo file_get_contents('./upload/YOURFILENAME.plist');
?>
You can easily recreate data in Xcode app.
Upvotes: 1
Reputation: 4577
I am not sure about PHP but you need to make one Method which accepts request from the iPhone app and return data in either xml or JSON format. Or you can send file too. if you send data in XML or JSON format then you need to do parsing for that.
Also, You can also get data in iPhone app using POST method. POST and GET method is just for parameter. It doesn't mean that you are going to Get data in GET Method.
Also, if you can try something and then come back then we can guide you appropriately. At this stage it is very difficult to take you on correct track.
First of all, do you PHP part and then think about iPhone code.
Hope this overview help.
Upvotes: 1