Hi,
I have a couple of working projects that use a WS5100 Ethernet Shield to access Tropo to send SMS messages. It all works fine, but now Tropo wants their users to access the api using https.
The sample sketch is below:
#include <Ethernet.h>
#include <SPI.h>
#define TROPO_SMS_TOKEN ".... my token is really in here. Delete it to post on this forum......."
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0x81, 0xED };
byte ip[] = { 192, 168, 1, 127 }; // home LAN
IPAddress gateway( 192, 168, 1, 1 );
IPAddress subnet( 255, 255, 255, 0 );
char server[] = "api.tropo.com";
EthernetClient client;
void setup()
{
Serial.begin(9600);
Ethernet.begin(mac, ip); //, gateway, subnet); // start the Ethernet connection
delay(1000); // give the Ethernet shield a second to initialize
char mySMS[25];
strcpy(mySMS, "Hello+out+there");
sendSMS(mySMS);
}
void loop()
{
}
void sendSMS(char txtSMS[]) //client function to send/receive GET request data.
{
if (client.connect(server, 80))
{
Serial.println(F("connected"));
client.print("GET /1.0/sessions?action=create&token=");
client.print(TROPO_SMS_TOKEN);
client.print("&phone=6095551212&msg="); // phone number changed to protect the innocent
client.print(txtSMS);
client.println(" HTTP/1.0");
client.println("Host: http://api.tropo.com");
client.println(); //end of get request
}
else
{
Serial.println(F("Connection failed")); //error message if no client connect
}
while(client.connected() && !client.available()) delay(1); //waits for data
while (client.connected() || client.available())
{ //connected or data available
char c = client.read(); //gets byte from ethernet buffer
Serial.print(c); //prints byte to serial monitor
}
Serial.println(F("\n\ndisconnecting.\n"));
client.stop(); //stop client
}
As shown above, it works. If I change the server variable to either of:
char server[] = "http://api.tropo.com";
or
char server[] = "https://api.tropo.com";
It says it connects on the serial monitor but nothing happens after that.
Any ideas why adding just http:// would cause it to fail? I can understand that maybe adding https:// might cause a problem (it shoudn't), but why would adding http:// be a problem?
Any ideas?
Thanks.