无法使用curl与谷歌合作

时间:2013-07-12 18:23:57

标签: c# c++ api curl google-voice

所以我试图重做这段代码,但C ++ https://bitbucket.org/jitbit/sharpgooglevoice/src/0d76122c5bd7f4000352e003c9990d62f2421693/SharpGoogleVoice.cs?at=default

但是,我认为我的代码完全相同,但似乎没有用。

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);
}

然而没有任何反应。我知道Login()正常工作,因为我能够登录并检查消息。我的输出与C#代码中的输出相同,但出于某种原因,它不会做任何事情

url格式应为此 POST / voice / sms / send / phoneNumber = [number to text]& text = [URL Encoded message]& _rnr_se = [pull from page]

1 个答案:

答案 0 :(得分:0)

有些内容与您指向的原始代码不符;

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

当你正在使用时;

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

请注意不同的网址。也;

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

......当你正在使用......

string data = "sendphoneNumber=" + number;

请注意不同的参数名称。