11-13-2012 04:33 AM
I'm new to the whole blackberry app development and, so far I'm enjoying it, BUT, I'm getting gray hair from retrieving data from my localhost php file.
Can someone give me a straight forward quick tutorial on how to do this? I've been trying to follow online tutorials, but none of them EVER work!
So far, I've got everything up and running.
my php file echo's "hello", just for now....
How do I access that php file and display the echo?
This is what I'm trying at this moment.
HttpConnection http = null;
StreamConnection s = (StreamConnection)Connector.open(url);
HttpConnection httpConn = (HttpConnection)s;
int status = httpConn.getResponseCode();
It says Connector.open "Unhandled exception type IOException";
I would GREATLY appreciate some help.
11-13-2012 04:43 AM
11-13-2012 04:43 AM
You could probably start by using the HttpDemo sample.
However the trick here is probably that you do not know how to specify the connection method the device/simulator will use to connect, and you are probably being timed out. Printout the message associated with the IOException you are handling, to see more detail of the actual Io error it is complaining about.
To get default processing working on the Simulator, you need to start the MDS Simulator, or append ";deviceside=true" to your URL.
To appreciate the various options review this video:
To understand how to set the connection method manually, see this:
However I recommend you look at using ConnectionFactory, as Simon pointed out in response to your first post here:
Let us know if the above does not get you going.
Finally - welcome to BlackBerry. Hope you enjoy it!
11-13-2012 05:09 AM
The thing is, everything is so confusing.....I try to look at the coding samples, but It just doesn't make sense.
Does anyone know of a tutorial that will tell me, we do this because of this, and this because of that, nothing fancy, I just want to retrieve some text, that's all.
I followed this, but even that doesn't work, it's too messy and complicated for the little basic thing I want to achive.
Thanks for the response.
11-13-2012 05:22 AM
11-13-2012 05:46 AM
okay i got it working making a change.
c = Connector.open("http://localhost:8080/home.php;dev
I changed the deviceside to true, but then it reads everything as text and ignores anything like html tags etc..
11-13-2012 05:48 AM
11-13-2012 06:12 AM
I think this is a case where a little knowledge will help you understand the framework you are building upon.
As an example, you don't just turn the key in your car and think that is what makes it go forward do you? You understand that it only turns the starter motor, which turns the motor .... A little knowledge about how the car works means you use it better.
I recommend that you review the links I pointed you at. They explain the connection methods and the meaning of the connection suffixes.