GSM SHIELD GET DATA FROM SERVER

Hello everyone,
I would like to remotely control an LED reading a string from a server (GET or POST). NO LOCALHOST
check the value of the incoming string from the server and activate the LED.

page in php performs a check on the variable and returns "1" or "'0"

The following part of the script:

#include <GSM.h>

#define PINNUMBER ""

// APN information obrained from your network provider
#define GPRS_APN "GPRS APN" // replace with your GPRS APN
#define GPRS_LOGIN "LOGIN" // replace with your GPRS login
#define GPRS_PASSWORD "PASSWORD" // replace with your GPRS password

// initialize the library instances
GSMClient client;
GPRS gprs;
GSM gsmAccess;

boolean notConnected;

char path[] = "/file.txt";
int port = 80; // port 80 is the default for HTTP

void setup()
{

Serial.begin(9600);
Serial.println("START");

notConnected = true;

Connect();

}

void loop()
{
if(client.connect("www.mydomain.com",80)){
Serial.println("connected!");
client.print("POST http://mydomain.com/arduino/read.php?temp=121221");
client.println(" HTTP/1.1");
client.println("Host: http://mydomain.com");
client.println();
client.stop();

} else {
Serial.println("connection failed");
Serial.println("\n FAILED!\n");
}

}

void Connect(){
while(notConnected)
{
if(gsmAccess.begin()){
Serial.println("GSM OK");
if(gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD)){
Serial.println("GPRS OK");
notConnected = false;
}
}
else
{
Serial.println("Not connected");
delay(1000);
}
}
}

I thank you in advance.

help!!!!!!!
=( =( =( =( =( =( =( =( =( =( =( =( =( =( =(

The following part of the script

So, what problem are you having?

Why are you not reading (and storing) the server response?

how can I intercept the server's response?
usually displays error "bad request" HTTP 302 other times FOUND.

how can I intercept the server's response?

Using client.connected(), client.available(), and client.read().

usually displays error "bad request" HTTP 302 other times FOUND.

What does? Where?

Use This:

if(client.connect("www.mydomain.com",80)){
Serial.println("connected!");
client.print("POST http://mydomain.com/prova.php?temp=121221");
client.println(" HTTP/1.1");
client.println("Host: http://mydomain.com");
client.println();

if (client.available()) {
char c = client.read();
Serial.print(c);
}

client.stop();
......

how can I intercept the text of the page php?

THIS IS RESULT:

HTTP/1.1 302 Found
Date: Thu, 11 Sep 2014 16:39:21 GMT
Server: Apache
Location: https://www.*******.com/prova.php?q=data
Content-Length: 291
Connection: close
Content-Type: text/html; charset=iso-8859-1

302 Found

Found

The document has moved here.


Apache Server at *******.com Port 80 disconnecting.

how can I intercept the text of the page php?

I presume that you mean that you want to collect the output from the script running on the server.

if (client.available()) {
    char c = client.read();
    Serial.print(c);
  }

This code should be a while statement, not an if statement, and should be in a if(client.connected()) block.

To save the data in an array is pretty simple, isn't it?

THIS IS RESULT:

HTTP/1.1 302 Found

Which means that the script is not where you think it is, but it left a forwarding address. The script was NOT run, so collecting that data in an array seems pointless.

Was there something different in the two parts you redacted?

    client.println("Host: http://mydomain.com");

The http:// part defines the protocol to use to talk to the host. It is NOT part of the host name OR the POST request.