url may be wrong, i adapting existing code to do put's, i calculating url
manually from spreadsheets metafeed, i extracting spreadsheet id, when
puting it in right place in url, look on my code
while(node)
{
bool found = false;
string spreadshit_id;
xml_node<> *id = node->first_node("id");
spreadshit_id = id->value();
xml_node<> *link = node->first_node("link");
while(link)
{
string href;
for (xml_attribute<> *attr =
link->first_attribute(); attr; attr = attr->next_attribute())
{
if(!strcmp(attr->name(), "href"))
href = attr->value();
if(!href.empty() && !spreadshit_id.empty())
{
wstring tmp = toUTF16(attr->value());
if(tmp.find(Params.vtszDocuments[0]) !=
wstring::npos)
{
spreadshit_id.erase(0,
spreadshit_id.find_last_of("/")+1);
SpreadsheetId = spreadshit_id;
found = true;
}
}
if(found)
break;
}
if(found)
break;
link = link->next_sibling("link");
}
if(found)
break;
node = node->next_sibling("entry");
}
here i parsing data from
https://spreadsheets.google.com/feeds/spreadsheets/private/full, maybe exist
better way for doing this, but i have existsing workgin code and want just
adapt it, *Params.vtszDocuments[0]* is spreadsheet key, after getting
spreadsheet id i creating link and data with this code
string str =
"https://spreadsheets.google.com/feeds/cells/";
str += toUTF8(Params.vtszDocuments[0]);
str += "/";
str += SpreadsheetId;
str += "/private/full/";
str += make_cell(i->column+1, i->row+1);
nlhr.szUrl = _strdup(str.c_str());
(here i using 1-based values as you can see), make_cell just creating R0C0
reoresentation of integer values, in following code i creating xml data for
put request
string str = "<entry
xmlns=\"http://www.w3.org/2005/Atom\"
xmlns:gs=\"http://schemas.google.com/spreadsheets/2006\"><id>";
str += nlhr.szUrl;
str += "</id><link rel=\"edit\"
type=\"application/atom+xml\" href=\"";
str += nlhr.szUrl;
str += "\"/><gs:cell row=\"";
char buf[5];
_itoa(i->column+1, buf, 10);
str += buf;
str += "\" col=\"";
_itoa(i->row+1, buf, 10);
str += buf;
str += "\" inputValue=\"";
str += toUTF8(msg);
str += "\"/></entry>";
i have also checked with xml parsing library i getting same result, but for
tgis simple situation this code more shorter