2009-11 << 2009-12 >> 2010-01

2009-12-04 (金)

*mixiにログインする方法

とりあえず,C++で.Cookie取れない場合は失敗.

#include <iostream>
#include "../cppfl/http.h"
#include "../cppfl/stringex.h"
using namespace std;
using namespace Net;

int main(int argc,int argv[])
{
    map<string,string> params;

    params["email"] = "mail@example.com";
    params["password"] = "********";
    params["next_url"] = "/home.pl";

    HttpClient hc;
    hc.load("http://mixi.jp/login.pl",params);

    string cookie;
    for (int i=0;i<hc.headers["Set-Cookie"].size();i++) {
        cookie += (hc.headers["Set-Cookie"][i]*split(" "))[0];
    }

    hc.clear();
    hc.req_header["Cookie"] =  cookie;
    hc.load("http://mixi.jp/run_appli.pl?id=6598");
    cout << hc.body << endl;

    return 0;
}

書いていて,*split(" ")が気色悪かったので,何か考えよう.

2009-11 << 2009-12 >> 2010-01