в чем может быть дело:
- Код: Выделить всё
public static class ExampleSendCall
{
public static string SendCall(string uid, string userlogin, string password, string telephone1, string telephone2)
{
var str = new SortedDictionary<string, string>
{
{"action", "call"},
{"maxdur", "59"},
{"number1", telephone1},
{"number2", telephone2},
{"uid", uid},
{"useivr", "0"},
{"username", userlogin}
};
var key = SendSmsCore.BuildUrlParamsWithSignature(str, password);
var parurl = String.Format("http://api.comtube.com/scripts/api/callback.php?{0}", key);
return parurl;
}
}
public static class ExampleSendCallNo
{
public static string SendCallNo(string uid2, string userlogin2, string password2)
{
var str2 = new SortedDictionary<string, string>
{
{"action", "terminate"},
{"uid", uid2},
{"username", userlogin2}
};
var key2 = SendSmsCore.BuildUrlParamsWithSignature(str2, password2);
var parurl2 = String.Format("http://api.comtube.com/scripts/api/callback.php?{0}", key2);
return parurl2;
}
}
internal static class SendSmsCore
{
private static string GetMd5Sum(string str)
{
var md5 = MD5.Create();
var inputBytes = Encoding.ASCII.GetBytes(str);
var hash = md5.ComputeHash(inputBytes);
var sb = new StringBuilder();
foreach (var t in hash)
sb.Append(t.ToString("X2"));
return sb.ToString();
}
public static string BuildUrlParamsWithSignature(SortedDictionary<string, string> parms, string password)
{
var url = "";
foreach (var kvp in parms)
{
string val;
if (kvp.Key != "message")
{
val = kvp.Key != "when" ? HttpUtility.UrlEncode(kvp.Value.Trim()) : Uri.EscapeDataString(kvp.Value).Replace("%20", "+");
}
else
{
val = Uri.EscapeDataString(kvp.Value).Replace("%20", "+");
}
url += kvp.Key + "=" + val + "&";
}
var sign = GetMd5Sum(url + "&password=" + Uri.EscapeDataString(password));
url += "signature=" + sign.ToLower();
return url;
}
}