[android-developers] Re: Call PHP through URL

2010-09-04 Thread svebee
Tnx. Can you tell me what's the simplest way to do this...

I send some data to my PHP script, it calculates some data and outputs
String ABC123 on a screen (with PHP echo function). Then how can I
grab it and receive into my Android activity? Do I need to use JSON
(http://snipplr.com/view/4717/output-json-string-from-php/) ?

On Sep 4, 1:43 am, Mark Murphy mmur...@commonsware.com wrote:
 Use HttpClient, which is included in the Android firmware:

 http://hc.apache.org/httpcomponents-client-4.0.1/index.html

 On Fri, Sep 3, 2010 at 7:40 PM, svebee sven.kapud...@gmail.com wrote:
  Hi,

  how can I call (without any browser or so) some URL to activate PHP
  script on my server..for ex.

  URL = http://www.website.com/script.php?id=; + someVariable;
  call/execute URL;

 --
 Mark Murphy (a Commons 
 Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy

 _The Busy Coder's Guide to Android Development_ Version 3.1 Available!

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: Call PHP through URL

2010-09-04 Thread Filip Havlicek
No, you just download the webpage as usual, it will contain the information
you echoed. You form the webpage URL as a normal browser-like URL with
parameters you want to send to your PHP script.

Best regards,
Filip Havlicek

2010/9/4 svebee sven.kapud...@gmail.com

 Tnx. Can you tell me what's the simplest way to do this...

 I send some data to my PHP script, it calculates some data and outputs
 String ABC123 on a screen (with PHP echo function). Then how can I
 grab it and receive into my Android activity? Do I need to use JSON
 (http://snipplr.com/view/4717/output-json-string-from-php/) ?

 On Sep 4, 1:43 am, Mark Murphy mmur...@commonsware.com wrote:
  Use HttpClient, which is included in the Android firmware:
 
  http://hc.apache.org/httpcomponents-client-4.0.1/index.html
 
  On Fri, Sep 3, 2010 at 7:40 PM, svebee sven.kapud...@gmail.com wrote:
   Hi,
 
   how can I call (without any browser or so) some URL to activate PHP
   script on my server..for ex.
 
   URL = http://www.website.com/script.php?id=; + someVariable;
   call/execute URL;
 
  --
  Mark Murphy (a Commons Guy)http://commonsware.com|
 http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy
 
  _The Busy Coder's Guide to Android Development_ Version 3.1 Available!

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en


-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: Call PHP through URL

2010-09-04 Thread svebee
Something like - 
http://www.anddev.org/novice-tutorials-f8/doing-http-post-with-the-current-sdk-t5911.html
?

Just one thing isn't clear to me - what represents this line

nameValuePairs.add(new BasicNameValuePair(id, 12345));

- especially (id, 12345) - I think that id is the key and
12345 the value, but where to put the key in the webpage?

On Sep 4, 11:32 am, Filip Havlicek havlicek.fi...@gmail.com wrote:
 No, you just download the webpage as usual, it will contain the information
 you echoed. You form the webpage URL as a normal browser-like URL with
 parameters you want to send to your PHP script.

 Best regards,
 Filip Havlicek

 2010/9/4 svebee sven.kapud...@gmail.com

  Tnx. Can you tell me what's the simplest way to do this...

  I send some data to my PHP script, it calculates some data and outputs
  String ABC123 on a screen (with PHP echo function). Then how can I
  grab it and receive into my Android activity? Do I need to use JSON
  (http://snipplr.com/view/4717/output-json-string-from-php/) ?

  On Sep 4, 1:43 am, Mark Murphy mmur...@commonsware.com wrote:
   Use HttpClient, which is included in the Android firmware:

  http://hc.apache.org/httpcomponents-client-4.0.1/index.html

   On Fri, Sep 3, 2010 at 7:40 PM, svebee sven.kapud...@gmail.com wrote:
Hi,

how can I call (without any browser or so) some URL to activate PHP
script on my server..for ex.

URL = http://www.website.com/script.php?id=; + someVariable;
call/execute URL;

   --
   Mark Murphy (a Commons Guy)http://commonsware.com|
 http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy

   _The Busy Coder's Guide to Android Development_ Version 3.1 Available!

  --
  You received this message because you are subscribed to the Google
  Groups Android Developers group.
  To post to this group, send email to android-developers@googlegroups.com
  To unsubscribe from this group, send email to
  android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Call PHP through URL

2010-09-04 Thread Jason
I was LITERALLY just coding this to submit a POST to google app
engine.

This code works for me (1.6 compatible.. and probably 1.5 actually):

HttpClient client = new DefaultHttpClient();

HttpPost post = new HttpPost(https://someurl.com;);

ListNameValuePair nvps = new 
ArrayListNameValuePair(2);

nvps.add(new BasicNameValuePair(key1, somevalue1);
nvps.add(new BasicNameValuePair(key2, somevalue2);

post.setEntity(new UrlEncodedFormEntity(nvps, 
HTTP.UTF_8));

client.execute(post);



On Sep 5, 5:46 am, svebee sven.kapud...@gmail.com wrote:
 Something like 
 -http://www.anddev.org/novice-tutorials-f8/doing-http-post-with-the-cu...
 ?

 Just one thing isn't clear to me - what represents this line

 nameValuePairs.add(new BasicNameValuePair(id, 12345));

 - especially (id, 12345) - I think that id is the key and
 12345 the value, but where to put the key in the webpage?

 On Sep 4, 11:32 am, Filip Havlicek havlicek.fi...@gmail.com wrote:



  No, you just download the webpage as usual, it will contain the information
  you echoed. You form the webpage URL as a normal browser-like URL with
  parameters you want to send to your PHP script.

  Best regards,
  Filip Havlicek

  2010/9/4 svebee sven.kapud...@gmail.com

   Tnx. Can you tell me what's the simplest way to do this...

   I send some data to my PHP script, it calculates some data and outputs
   String ABC123 on a screen (with PHP echo function). Then how can I
   grab it and receive into my Android activity? Do I need to use JSON
   (http://snipplr.com/view/4717/output-json-string-from-php/) ?

   On Sep 4, 1:43 am, Mark Murphy mmur...@commonsware.com wrote:
Use HttpClient, which is included in the Android firmware:

   http://hc.apache.org/httpcomponents-client-4.0.1/index.html

On Fri, Sep 3, 2010 at 7:40 PM, svebee sven.kapud...@gmail.com wrote:
 Hi,

 how can I call (without any browser or so) some URL to activate PHP
 script on my server..for ex.

 URL = http://www.website.com/script.php?id=; + someVariable;
 call/execute URL;

--
Mark Murphy (a Commons Guy)http://commonsware.com|
  http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy

_The Busy Coder's Guide to Android Development_ Version 3.1 Available!

   --
   You received this message because you are subscribed to the Google
   Groups Android Developers group.
   To post to this group, send email to android-developers@googlegroups.com
   To unsubscribe from this group, send email to
   android-developers+unsubscr...@googlegroups.comandroid-developers%2Bunsubs
cr...@googlegroups.com
   For more options, visit this group at
  http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Call PHP through URL

2010-09-04 Thread Jason
oops.. just read your previous post

Then how can I grab it and receive into my Android activity?

The line in the code I posted:

client.execute(post);

actually also returns a response:

HttpResponse res = client.execute(post);

So if your PHP script is printing out data to the http response on the
server, this object will have that data.

You'll have to read the javadoc for this HttpResponse object as I'm
not sure where (i.e what structure) your data will be.  Usually if
it's just a small amount of data I just throw it into an HTTP Response
header on the server side.  That way the response is light and easier
to parse out because you can just call getHeaders on the HttpResponse
object.


On Sep 5, 5:46 am, svebee sven.kapud...@gmail.com wrote:
 Something like 
 -http://www.anddev.org/novice-tutorials-f8/doing-http-post-with-the-cu...
 ?

 Just one thing isn't clear to me - what represents this line

 nameValuePairs.add(new BasicNameValuePair(id, 12345));

 - especially (id, 12345) - I think that id is the key and
 12345 the value, but where to put the key in the webpage?

 On Sep 4, 11:32 am, Filip Havlicek havlicek.fi...@gmail.com wrote:



  No, you just download the webpage as usual, it will contain the information
  you echoed. You form the webpage URL as a normal browser-like URL with
  parameters you want to send to your PHP script.

  Best regards,
  Filip Havlicek

  2010/9/4 svebee sven.kapud...@gmail.com

   Tnx. Can you tell me what's the simplest way to do this...

   I send some data to my PHP script, it calculates some data and outputs
   String ABC123 on a screen (with PHP echo function). Then how can I
   grab it and receive into my Android activity? Do I need to use JSON
   (http://snipplr.com/view/4717/output-json-string-from-php/) ?

   On Sep 4, 1:43 am, Mark Murphy mmur...@commonsware.com wrote:
Use HttpClient, which is included in the Android firmware:

   http://hc.apache.org/httpcomponents-client-4.0.1/index.html

On Fri, Sep 3, 2010 at 7:40 PM, svebee sven.kapud...@gmail.com wrote:
 Hi,

 how can I call (without any browser or so) some URL to activate PHP
 script on my server..for ex.

 URL = http://www.website.com/script.php?id=; + someVariable;
 call/execute URL;

--
Mark Murphy (a Commons Guy)http://commonsware.com|
  http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy

_The Busy Coder's Guide to Android Development_ Version 3.1 Available!

   --
   You received this message because you are subscribed to the Google
   Groups Android Developers group.
   To post to this group, send email to android-developers@googlegroups.com
   To unsubscribe from this group, send email to
   android-developers+unsubscr...@googlegroups.comandroid-developers%2Bunsubs
cr...@googlegroups.com
   For more options, visit this group at
  http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en