[era]nie działa bramka sponsorowana

viater viater w poczta.fm
Pią, 14 Lis 2008, 13:24:20 CET


Dnia 2008-11-14 00:41, Szymon Zygmunt napisał(a) takiego oto mejla:
> Witam,
> 
> przy próbie wysłania sms przez w/w bramkę:
> 
> Unhandled exception in main: [2] - nie widzę tokena?!
> 
> Na stronie ery mogę wysłać bez problemu, ale na pierwszy rzut oka widać,
> że coś pozmieniali. Jak by ktoś wyprodukował jakiegoś patcha to mile
> widziany.
> 
> Pozdrawiam.

Jakiś czas temu ktoś mi sygnalizował problem z tą bramką, jednak nie mam
jak sprawdzić. Ten ktoś podesłał mi zmodyfikowany plik era.cc (poniżej)
- jak byś mógł sprawdzić, czy to rzeczywiście działa i dał mi znać, to
wrzuciłbym to na swoją stronę.


#include "mr_pcre/mr_pcre.h"
#include "era.h"

using namespace std;

EraSMS::EraSMS(Config &config) : GenericSMS(config)
{
   omnix_user = config["omnix_user"];
   omnix_pass = config["omnix_pass"];
}


bool EraSMS::Send(const std::string &phone_no, const std::string &message)
{
   bool ok;
   CURLcode status;
   Curl_Form form;
   string token;
   long int remaining, remainingAfterSend;

   curl.SSL_ignore();
   curl.AutoReferer();
   curl.FollowLocation();
   curl.UserAgent("Mozilla/5.0 Galeon/1.2.7 (X11; Linux i686; U;)
Gecko/20021216");
   curl.SetOpt(CURLOPT_COOKIEFILE, "");

   status =
curl.PerformGet("http://www.eraomnix.pl/msg/user/sponsored/welcome.do"
      "?mg_id=23882");
   if (status)
      throw Exception("[1] - get http://www.eraomnix.pl/msg/user/sponsored/"
            "welcome.do?mg_id=23882");

   status =
curl.PerformGet("http://www.eraomnix.pl/msg/user/login?mode=direct");
   if (status)
      throw Exception("[1] - get
http://www.eraomnix.pl/msg/user/login?mode=direct");

   PcreWrap::Array match;

   if (PcreWrap::pcre_match_all("rid\" value=\"(.*)\"", curl.Body(), "",
match))
      token = match[0][0];
   else
      throw Exception("[2] - nie widzę tokena?!");

   form.AddField("request", "login1");
   form.AddField("rid", token);
   form.AddField("sso-server", "authserver");
   form.AddField("user", omnix_user);
   form.AddField("password", omnix_pass);

   status = curl.PerformPost("http://sso.era.pl/sso/authserver/server",
      form.PostFields());
   if (status)
      throw Exception("[2] - post http://sso.era.pl/sso/authserver/server");

   status =
curl.PerformGet("http://www.eraomnix.pl/msg/user/sponsored/welcome.do?mg_id=23883");
   if (status)
      throw Exception("[2] - get
http://www.eraomnix.pl/msg/user/sponsored/welcome.do?mg_id=23882");

   if (PcreWrap::pcre_match_all("Pozosta.o SMS.w: <b>([0-9]+)</b>",
      curl.Body(), "mi", match)) {
      remaining = strtol(match[0][0].c_str(), NULL, 10);
   } else
      throw Exception("[2] - Błąd przy logowaniu");

   if (remaining < 0)
      throw Exception("[2] - nie można odczytać limitu wiadomości");
   if (remaining == 0)
      throw Exception("[2] - Limit wiadomości na dziś przekroczony");

   if (PcreWrap::pcre_match_all("TOKEN\" value=\"(.*)\"", curl.Body(), "mi",
      match))
      token = match[0][0].c_str();
   else
      throw Exception("[2] - nie widzę tokena?!");

   form.Reset();
   form.AddField("top.phoneReceiver", phone_no.substr(3));
   form.AddField("top.text", message);
   form.AddField("org.apache.struts.taglib.html.TOKEN", token);
   form.AddField("top.signature", "");
   form.AddField("top.characterLimit", "99");
   form.AddField("send", "0");
   form.AddField("mmsTab", "mmsTab");
   form.AddField("send_x", "15");
   form.AddField("send_y", "13");

   status =
curl.PerformPost("http://www.eraomnix.pl/msg/user/sponsored/sms.do",
      form.PostFields());
   if (status)
      throw Exception("[3] -
http://www.eraomnix.pl/msg/user/sponsored/sms.do");

   if (PcreWrap::pcre_match_all("Pozosta.o SMS.w: <b>([0-9]+)</b>",
curl.Body(),
      "mi", match))
      remainingAfterSend = strtol(match[0][0].c_str(), NULL, 10);
   else
      throw Exception("[3] - nie można odczytać limitu wiadomości");

   if (remainingAfterSend < 0)
      throw Exception("[3] - nie można odczytać limitu wiadomości");
   if (remaining <= remainingAfterSend)
      throw Exception("[3] - STATUS NIEZNANY, nie wiadomo czy wiadomość
została wysłana");

   status = curl.PerformGet("http://www.eraomnix.pl/login/logout.do");
   if (status)
      throw Exception("4 - SMS wysłany, ale błąd podczas wylogowywania");

   return ok;
}

bool EraSMS::ShowStats()
{
   bool ok = false;
   CURLcode status;
   Curl_Form form;
   string token;
   long int remaining;

   curl.SSL_ignore();
   curl.AutoReferer();
   curl.FollowLocation();
   curl.UserAgent("Mozilla/5.0 Galeon/1.2.7 (X11; Linux i686; U;)
Gecko/20021216");
   curl.SetOpt(CURLOPT_COOKIEFILE, "");

   status =
curl.PerformGet("http://www.eraomnix.pl/msg/user/sponsored/welcome.do"
      "?mg_id=23882");
   if (status)
      throw Exception("[1] - get http://www.eraomnix.pl/msg/user/sponsored/"
            "welcome.do?mg_id=23882");

   status =
curl.PerformGet("http://www.eraomnix.pl/msg/user/login?mode=direct");
   if (status)
      throw Exception("[1] - get
http://www.eraomnix.pl/msg/user/login?mode=direct");

   PcreWrap::Array match;

   if (PcreWrap::pcre_match_all("rid\" value=\"(.*)\"", curl.Body(), "",
match))
      token = match[0][0];
   else
      throw Exception("[2] - nie widzę tokena?!");

   form.AddField("request", "login1");
   form.AddField("rid", token);
   form.AddField("sso-server", "authserver");
   form.AddField("user", omnix_user);
   form.AddField("password", omnix_pass);

   status = curl.PerformPost("http://sso.era.pl/sso/authserver/server",
      form.PostFields());
   if (status)
      throw Exception("[2] - post http://sso.era.pl/sso/authserver/server");

   status =
curl.PerformGet("http://www.eraomnix.pl/msg/user/sponsored/welcome.do?mg_id=23883");
   if (status)
      throw Exception("[2] - get
http://www.eraomnix.pl/msg/user/sponsored/welcome.do?mg_id=23882");

   if (PcreWrap::pcre_match_all("Pozosta.o SMS.w: <b>([0-9]+)</b>",
      curl.Body(), "mi", match)) {
      remaining = strtol(match[0][0].c_str(), NULL, 10);
      ok = true;
   } else
      throw Exception("[2] - Błąd przy logowaniu");

   cout << "Pozostażo SMSów: " << remaining << endl;

    status = curl.PerformGet("http://www.eraomnix.pl/login/logout.do");

   return ok;
}


Dzwon tanio do wszystkich!
Sprawdz >> http://link.interia.pl/f1f93




Więcej informacji o liście dyskusyjnej Sms-users