Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development > iPhone SDK Development - Advanced Discussion

Reply
 
LinkBack Thread Tools Display Modes
Old 10-01-2010, 02:54 AM   #1 (permalink)
Registered Member
 
jimmy's Avatar
 
Join Date: Aug 2010
Posts: 52
jimmy is on a distinguished road
Default PHP with Iphone

i want to retrieve some array data from a server .I am using php script on the server.how do i do that ?

//Iphone Sdk Code
NSString* urlstr = @"http://xxxxxx.com/data.php";
NSURL *url = [[NSURL alloc] initWithString:urlstr];
NSArray *aray = [NSArray arrayWithContentsOfURL:url];

//PHP Code
<?php
// data.php file

$name = array('one','two','three');
return $name;
?>
jimmy is offline   Reply With Quote
Old 10-01-2010, 09:48 AM   #2 (permalink)
Registered Member
 
Join Date: Nov 2009
Posts: 23
harmar is on a distinguished road
Default

Quote:
Originally Posted by jimmy View Post
i want to retrieve some array data from a server .I am using php script on the server.how do i do that ?

//Iphone Sdk Code
NSString* urlstr = @"http://xxxxxx.com/data.php";
NSURL *url = [[NSURL alloc] initWithString:urlstr];
NSArray *aray = [NSArray arrayWithContentsOfURL:url];

//PHP Code
<?php
// data.php file

$name = array('one','two','three');
return $name;
?>
I use the JSON Parser (json-framework - Project Hosting on Google Code)
Then you can do
Code:
NSString *json = [[NSString alloc] initWithContentsOfURL:[NSURL URLWithString:@"http://xxxxxx.com/data.php"]];
				NSArray *data = (NSArray *) [jsonParser objectWithString:json error:NULL];
				[json release];
harmar is offline   Reply With Quote
Old 10-03-2010, 09:58 PM   #3 (permalink)
Registered Member
 
jimmy's Avatar
 
Join Date: Aug 2010
Posts: 52
jimmy is on a distinguished road
Default JsonParse Error

Quote:
Originally Posted by harmar View Post
I use the JSON Parser (json-framework - Project Hosting on Google Code)
Then you can do
Code:
NSString *json = [[NSString alloc] initWithContentsOfURL:[NSURL URLWithString:@"http://xxxxxx.com/data.php"]];
				NSArray *data = (NSArray *) [jsonParser objectWithString:json error:NULL];
				[json release];


'JsonParser' undeclared error .....i think i have to declare the jsonParser..help me with this ...
jimmy is offline   Reply With Quote
Old 10-04-2010, 04:23 AM   #4 (permalink)
Registered Member
 
jimmy's Avatar
 
Join Date: Aug 2010
Posts: 52
jimmy is on a distinguished road
Default

Quote:
Originally Posted by jimmy View Post
'JsonParser' undeclared error .....i think i have to declare the jsonParser..help me with this ...

I still get the same error.I attached the Class file from the Json Framework

SBJsonParser *jsonParser =[[SBJsonParser alloc]init];
NSString *rawJSON = [[NSString alloc] initWithContentsofURL:[NSURL URLWithString:@"http://xxxxx.asasa.com/edm.php"]];
NSArray *data = (NSArray *) [jsonParser objectWithString:rawJSON error:NULL];

Last edited by jimmy; 10-04-2010 at 04:25 AM.
jimmy is offline   Reply With Quote
Old 10-04-2010, 04:24 AM   #5 (permalink)
Registered Member
 
jimmy's Avatar
 
Join Date: Aug 2010
Posts: 52
jimmy is on a distinguished road
Default

Quote:
Originally Posted by jimmy View Post
'JsonParser' undeclared error .....i think i have to declare the jsonParser..help me with this ...

I still get the same error.I attached the Class file from the Json Framework

SBJsonParser *jsonParser =[[SBJsonParser alloc]init];
NSString *rawJSON = [[NSString alloc] initWithContentsofURL:[NSURL URLWithString:@"http://xxxx.hdsfphp.com/edm.php"]];
NSArray *data = (NSArray *) [jsonParser objectWithString:rawJSON error:NULL];

Last edited by jimmy; 10-05-2010 at 09:56 PM.
jimmy is offline   Reply With Quote
Old 10-05-2010, 06:00 AM   #6 (permalink)
Registered Member
 
jimmy's Avatar
 
Join Date: Aug 2010
Posts: 52
jimmy is on a distinguished road
Default Json for ServerData




As you can see the Json Classes from the Framework .i dont have SBJson file.Is that a problem.Help me.I downloaded the Json Framework file from the link u provided.Am i missing something?

Please Check the link below to see the Xcode classes for the JSon Framework.
http://ajitthakali.hyperphp.com/json.png

Last edited by jimmy; 10-05-2010 at 09:58 PM.
jimmy is offline   Reply With Quote
Old 10-24-2010, 08:03 PM   #7 (permalink)
Registered Member
 
Join Date: Oct 2010
Posts: 9
dciso is on a distinguished road
Default

I personally find using property list (plist) files alot easier. For example in one of my apps for a shop I have products saved in plist files which are created from a php script which is runs every hour to keep them up to date. Alternatively if they do a search I pass it to a php script that creates result.plist. Just do a quick search on google and you will find loads of tutorials: I use cfpropertylist in my php script to create the plist files.
dciso is offline   Reply With Quote
Reply

Bookmarks

Tags
php, php script, server

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 386
16 members and 370 guests
AragornSG, ChrisYates, coolman, davejas69, givensur, hussain1982, iAppDeveloper, jbro, Kryckter, locombiano89, Mah6447, Meoz, stanny, stevenkik, Tomsky, WeaselPig
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,646
Threads: 94,111
Posts: 402,862
Top Poster: BrianSlick (7,990)
Welcome to our newest member, locombiano89
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 05:46 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0