0

So I am trying to redo this code but C++ https://bitbucket.org/jitbit/sharpgooglevoice/src/0d76122c5bd7f4000352e003c9990d62f2421693/SharpGoogleVoice.cs?at=default

However, I think my code is identical but it doesn't seem to be working.

int SendSMS(string number, string msg)
{
 Login();

 curl_easy_setopt(curl, CURLOPT_URL, "https://www.google.com/voice/sms/");
 curl_easy_setopt(curl, CURLOPT_POST, 1);
 number = curl_easy_escape(curl, number,0);
 rnr_se = curl_easy_escape(curl, rnr_se.c_str(),0);
 string data = "sendphoneNumber=" + number;
 data += "&text=" + msg;
 data += "&_rnr_se=" + rnr_se;
 curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data.c_str());
 cr = curl_easy_perform(curl);
}

However nothing happens. I know Login() works correctly as I am able to Login and check the messages. My output is the same output as in the C# code but for some reason this doesnt do anything

The url format should be this POST /voice/sms/send/ phoneNumber=[number to text]&text=[URL Encoded message]&_rnr_se=[pull from page]

user2574427
  • 51
  • 1
  • 1
  • 6

1 Answers1

0

There are a few things that don't match the original code you're pointing to;

_webClient.UploadData("https://www.google.com/voice/sms/send"...

while you're using;

curl_easy_setopt(curl, CURLOPT_URL, "https://www.google.com/voice/sms/");

Note the different URL. Also;

PostParameters(new Dictionary<string, string>
    {
        {"phoneNumber", number},
...

...while you're using...

string data = "sendphoneNumber=" + number;

Note the different parameter name.

Joachim Isaksson
  • 176,943
  • 25
  • 281
  • 294
  • The URL isn't different we just have it formatted differently. They use /voice/sms/send but later on add the phoneNumber. so it becomes /voice/sms/sendphoneNumber while I say /voice/sms/ but later on add sendphoneNumber so it then becomes /voice/sms/sendphoneNumber – user2574427 Jul 12 '13 at 18:35
  • I might be mistaken but I thought I use curl_easy_setopt to get everything set up and then I use curl_easy_perform(curl) to actually send the data. I thought curl-easy_perform would be equivalent of _webClient.UploadData – user2574427 Jul 12 '13 at 18:47
  • @user2574427 As far as I can see, they always use just `https://www.google.com/voice/sms/send` as an URL, and `phoneNumber`, `text` and `_rnr_se` should be passed as `POST` parameters in the `POST` data, ie not at all in the URL. `GET` data is passed in the URL, `POST` data is not. – Joachim Isaksson Jul 13 '13 at 07:04