Parse incoming text

Hey!

I'm working on a Shirt that displays if I have any kind of notification on my Facebook profile. So i wrote a script that get's all the data from the Facebook API. With the Arduino WiFly I'm connecting to the site, where I get the following data back (via Serial.write(WiFly.read());):

HTT/11 00 OK
Date: Mon, 03 Sep 2012 10:26:36 GMT
Server: Apah/2.2.16
X-Powered-By: PP/5.3.3-7+sqeee14
Set-Cooie HPSESSID=9d5d7835c52fdb830780ab2c6a6dfca; path=
Expires: Tu, 19 Nov 191 08:52:00 GMT
Cache-Cotrol: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma:nocche
Vary: Accept-Encodig
Content-Lngh: 35
Content-Type: text/html

pokes:7;messages:0;notifications5;

the important thing is

pokes:7;messages:0;notifications5;

What I want to do now is to save the numbers into different variables to be able to work with them. Can someone help me with that?
Thanks!

What I want to do now is to save the numbers into different variables to be able to work with them.

This is asked quite often, and a bit of searching should find you several threads with examples.

Basically, what you need to do is stop throwing the characters away. Save them in an array, starting with the content portion of the reply (the portion that follows the blank line). That requires that you determine what makes up a line ending. Is it \n, \r, \n\r, or \r\n? Whatever it is, when you see two combinations or individual characters in a row, that is the blank line.

Save the characters that follow into an array.

Then, when the end of message arrives (the client has no more data available and has disconnected), use strtok() (NOT strtok_r()) and atoi() to parse and use the data.

Thank you PaulS! I've searched for it a several times but never found something that really fits for me. Can you please link me a tutorial or something like that. With witch function would I be able to search for the "\n\n" characters?
Maybe I should explain to you that I'm totally new into that :drooling_face:

With witch function would I be able to search for the "\n\n" characters?

The == operator and a state machine.

First, though, just print each character you are reading twice (yes, that means you need to store it). First as a character then in HEX format.

char inChar = WiFly.read();
Serial.print(inChar);
Serial.print(" (");
Serial.print(inChar, HEX);
Serial.println(")");

This will let you learn exactly what character(s) denote a blank line.

There is a library for a utility called textfinder that can be used to get data out of a text stream. If the number of lines in the header is constant, you might count the line feed characters and save the text between the 13th and 14th line feed characters.