We are using the TropoSharp to send SMS message to my phone. The weird part is that I didn't get any SMS message, rather I get a phone call and it is very short and I could not figure out what the person is talking over the phone.
By looking at the code, we could not figure out what's wrong:
string voiceToken = "xxx";
string messagingToken = "xxx";
IDictionary<string, string> parameters = new Dictionary<String, String>();
parameters.Add("sendToNumber", "xxx");
parameters.Add("sendFromNumber", "+1 201-xxx-04xx");
string channel = Channel.Text;
parameters.Add("channel", channel);
string network = Network.SMS;
parameters.Add("network", network);
parameters.Add("msg", HttpUtility.UrlEncode("This is a test message from C#."));
Tropo tropo = new Tropo();
XmlDocument doc = new XmlDocument();
string token = channel == Channel.Text ? messagingToken : voiceToken;
doc.Load(tropo.CreateSession(token, parameters));
Console.WriteLine("Result: " + doc.SelectSingleNode("session/success").InnerText.ToUpper());
Console.WriteLine("Token: " + doc.SelectSingleNode("session/token").InnerText);
Console.ReadKey();
Here is the http request (removed some sensitive information)
GET http://api.tropo.com/1.0/sessions?action=create&token=xxxxx&sendToNumber=xxx&sendFromNumber=+1%20201-xxx-xxxx&channel=TEXT&network=SMS&msg=This+is+a+test+message+from+C%23.& HTTP/1.1
Host: api.tropo.com
Connection: Keep-Alive
here is the response (I guess it only means that request is submitted successful):
<session><success>true</success><token>xxxx</token><id>5c994e73ab85ff47fd1af4ffd4002e00
Any idea where we did wrong here? Thanks
You're using the scripting approach, not WebAPI, right? Can you post the script that your application is using? It's my understanding that when you create a session, you're just passing variables up to your script. Your script might be completely ignoring those variables, and just making a voice call.
I agree about your last point. That response just tells you that it succeeded in creating the session. It doesn't return any additional information about other steps of the process.
There are two tokens for your application, one for voice and one for messaging. Are you using the one for messaging? Also, outbound messaging is not turned on be default for your application. You have to contact Tropo support to turn it on for development. They may require you to put some money in your account to do this, but they will not charge you unless you start abusing this feature during development.
Related
I have inherited responsibility for a project from a previous developer which takes incoming emails and processes them into customer support tickets.
It mostly works fine but it is having problems with one particular email and I can't work out why.
In Outlook the email clearly has a body (some short text, an image and a signature). It is a new message and not a reply.
The exchange server version is 2013.
But when being processed by the code below UniqueBody is empty, while Body contains the correct text. This does not happen with any other emails I've come across on that server.
if (serverVersion >= ExchangeVersion.Exchange2010)
body = msg.UniqueBody.Text;
else
body = msg.Body.Text;
What would cause UniqueBody to be empty while Body is not?
Why would the previous developer prefer to use UniqueBody over Body, how do they differ?
Could be related to this?
Check if you request the properties correctly:
PropertySet ps = new PropertySet(ItemSchema.UniqueBody);
var email = EmailMessage.Bind(service, item.ItemId, ps);
If you do so, the UniqueBody-Property should not be empty.
As far as I know, UniqueBody should be set by the exchange-server to show you which part of the mail is relevant for your ticket:
https://msdn.microsoft.com/en-us/library/office/dd877075(v=exchg.150).aspx
If your customer answers later to the ticket-conversation, you only want the new text.
With a new mail/ticket: body == uniqueBody == "the text you want to use".
MailAddress Sender = new MailAddress("SomeOne#yahoo.com", "SomeOne", Encoding.UTF8);
SmtpClient Client = new SmtpClient("smtp.mail.yahoo.com",465);
Client.Credentials = new System.Net.NetworkCredential(Sender.Address,"Password",Domain??? );
just out of curiosity what is the third overload of NetworkCredential
I mean what we need to pass argument for Domain property . I searched on net but but no one used it(domain property) .I tried "Yahoo.com","#Yahoo.com","Yahoo" bot no every time same authentication error .It can be done without Domain property but where can we use it or what we can pass it .
The Domain property is used for NTLM authentication with Active Directory domains.
It is not used for normal login scenarios.
Whenever I call Bing Translation API [HTTP] to translate some text, first time it works fine, and second time onwards it gives me 'bad request' [status code 400] error. If I wait for 10 or so minutes and then try again, then first request is successful, but second one onwards same story. I have a free account [2million chars translation] with Bing Translation APIs, are there any other limitations calling this API?
Thanks, Madhu
Answer:
hi, i missed to subscribing to Microsoft Translator DATA set subscription. Once i get the same, then things have solved. i.e; once i have signed up for https://datamarket.azure.com/dataset/bing/microsofttranslator then things are working.
i was generating the access_token correctly, so that is not an issue.
thanks, madhu
i missed to subscribing to Microsoft Translator DATA set subscription. Once i get the same, then things have solved. i.e; once i have signed up for https://datamarket.azure.com/dataset/bing/microsofttranslator then things are working.
i was
thanks, madhu
As a note to anyone else having problems, I figured out that the service only allows the token to be used once when using the free subscription. You have to have a paid subscription to call the Translate service more than once with each token. This limitation is, of course, undocumented.
I don't know if you can simply keep getting new tokens -- I suspect not.
And regardless of subscription, the tokens do expire every 10 minutes, so ensure you track when you receive a token and get a new one if needed, e.g. (not thread-safe):
private string _headerValue;
private DateTime _headerValueCreated = DateTime.MinValue;
public string headerValue {
get {
if(_headerValueCreated < DateTime.Now.AddMinutes(-9)) {
var admAuth = new AdmAuthentication("myclientid", "mysecret");
_headerValue = "Bearer " + admAuth.GetAccessToken();
_headerValueCreated = DateTime.Now;
}
return _headerValue;
}
}
Is there any way to set more than one protobufEncoder/protobufDecoder?
Let me explain my problem.I have a command which will be send from the
client to the server,The server get the command and do some work according
to the command.Now the response ("answer") of the server could be:
for the length of string or is for the integer square (order not sure)
My question is now:what can I do that the client can receive at least two
different responses from the server? Both are "encoded" with Protobuf.And
in turn,what I need to do that the server can send at least two different
responses?Also both are "encoded" with Protobuf.both are "decoder" with protobuf.
ProtobufDecoder of netty to set two different protobufEncoder/Decoder is not possible.
Let us see below netty example, decoder can only receive a decoder object
LocalTimeServerPipelineFactory:
public ChannelPipeline getPipeline() throws Exception {
ChannelPipeline p = pipeline();
p.addLast("frameDecoder", new ProtobufVarint32FrameDecoder());
p.addLast("protobufDecoder", new ProtobufDecoder(LocalTimeProtocol.Locations.getDefaultInstance()));
p.addLast("frameEncoder", new ProtobufVarint32LengthFieldPrepender());
p.addLast("protobufEncoder", new ProtobufEncoder());
p.addLast("handler", new LocalTimeServerHandler());
return p;
}
thanks in advance and best regards.
quartz
You can adjust the ChannelPipeline on the fly. This should help you there. Just add/remove the right one when you need it.
I am trying to manage an Inbox in Exchange 2003 automatically using webdav from a C# application. Looking at msdn is not helping me a whole lot as the methods described here (http://msdn.microsoft.com/en-us/library/aa142917.aspx) do not coincide at all with the samples I have found otherwise. So there are two things I am trying to determine:
Of all the fields that return from a webdav query
string reqStr =
#"<?xml version=""1.0""?>
<g:searchrequest xmlns:g=""DAV:"">
<g:sql>
SELECT
*
FROM
""http://server/Exchange/email1#domain.com/Inbox/""
WHERE ""urn:schemas:mailheader:from"" = 'email2#domain.com'
</g:sql>
</g:searchrequest>";
Which one is the unique identifier? I have browsed it (but not sure of a reference to verify the fields) and it appears at first glance that DAV:id is what I want (), but I am not wanting to work on assumptions.
Secondly, what is the correct way to programmatically delete an email after I have processed it? Would something like the following work (will it remove the entry and all related metadata). I don't want any files left orphaned on the server...
string reqStr =
#"<?xml version=""1.0""?>
<g:searchrequest xmlns:g=""DAV:"">
<g:sql>
DELETE
FROM
""http://server/Exchange/email1#domain.com/Inbox/""
WHERE ""DAV:id"" = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXX'
</g:sql>
</g:searchrequest>";
And finally, what are the best online sources for investigating all the data returned in the XML from the first request, and where are all the options documented for managing the webdav interface? Looking at MSDN just hasn't been fruitful.
Look for the dav:hef tags tag in the response. They contain an url you can use to issue a delete command.
From the result of a query that gets you the msg Uri then:
var request = (HttpWebRequest)WebRequest.Create(mail.MailUri);
request.Credentials = _credential;
request.Method = "DELETE";
var response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode != HttpStatusCode.OK)
{
//something might of broke
}