I'm new to Twilio and I am trying to create a sample code for sending SMS to a number. I already created account on Twilio and written a program which is working good on local. but now going further that program is not able to send SMS from Prod server. what i can to know that we can communicate to external uri through proxy. so i implemented proxy in my code. below is the property which i set for proxy information in TwilioRestClient.
var twilio = new TwilioRestClient(AccountSid, AuthToken);
twilio.Proxy = new WebProxy("http://ProxyAddress", 8080);
But this code is not working after adding proxy to it. can any one help me in this. is this the right way of doing that?
Related
I am able to send SMS using C#. But my problem is I don't know to receive those SMS.
I looked into following documentation with WebHook and C# here:
https://developers.ringcentral.com/guide/notifications/quick-start/webhook/c-sharp
But not sure how to do it exactly.
Can I get any help to know how I can receive the SMS. Any sample will be great.
There are 3 ways to receive SMS:
PubNub Subscription
WebHook Subscription
API Request
Here are some details:
Using PubNub, you can receive SMS.
Check it out here: https://github.com/ringcentral/ringcentral-csharp-client/blob/master/RingCentral.Test/SubscripotionTest.cs#L31
Since this is used by PubNub, so you don't need ngrok
If you want WebHook, you need to subscribe for push notification check the reference demo: https://github.com/ringcentral/ringcentral-csharp-client/blob/master/RingCentral.Test/WebHookTest.cs
The direct API of RingCentral APIs to receive SMS content in your C#, by calling this API inside your SDK is: /restapi/v1.0/account/~/extension/~/message-store/{messageId}/content/{attachmentId}. Here you need to put the message id and the attachment id to retrieve message content from message-store
Hope this help.
I built a WCF Service that uses custom username and password authentication and I am testing it from the client app with the following code:
using (ServiceReferenceClient.TestServiceClient tc = new ServiceReferenceClient.TestServiceClient())
{
tc.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;
tc.ClientCredentials.UserName.UserName = "User1";
tc.ClientCredentials.UserName.Password = "Pwd1";
tc.ServiceMethod(param1, param2, param3);
}
It works fine but I need to see the actual SOAP request sent to the WCF service and response. How can I do that from my client?
I know I might have to write my own custom message inspector and would like some pointers on how to build one
The options mentioned in the comments above are good for testing. If you want something more robust that you can include in your code, then I think what you want to implement is a WCF Message Inspector.
More on how to do this on the client:
You can inspect or modify the incoming or outgoing messages across a
WCF client by implementing a
System.ServiceModel.Dispatcher.IClientMessageInspector and inserting
it into the client runtime.
https://msdn.microsoft.com/en-us/library/ms733786(v=vs.110).aspx
And a good example:
https://weblogs.asp.net/paolopia/writing-a-wcf-message-inspector
I am looking at implementing an SMS gateway to send SMS messages to phones from my application.
I was wondering if there are any services that would support sending of messages via AJAX from my views. So ideally, I would have a button on my page that calls the SMS service and passes a json message object to a SMS gateway and retrieves a response.
I'm more than happy building ajax post requests, but I have never used any form of SMS gateway so would appreciate any advice or pointers.
Many thanks
If I understand correctly you would like to use some paid SMS gateway provider like Twilio.
Sending sms via ajax from client application is possible but should not be done in public avaliable websites. Using REST api provided by Twilio you must provide authToken and sid these two will be avaliable for everyone who see your view, so everyone will have possibility to send sms/mms on your cost.
Correct architecture for such solution is to pass custom ajax request to your own server and then in private back end use gateway API library.
This topic was already raised, for example here:
Backbone/JS: looking to access the Twilio SMS API via an AJAX call
Here https://www.twilio.com/docs/libraries you can find libraries for all modern server technologies like .Net, Node.ja, Ruby etc.
And here is a little sample how to send a SMS from C#.
using System;
using Twilio;
class Example
{
static void Main(string[] args)
{
// Find your Account Sid and Auth Token at twilio.com/user/account
string AccountSid = "AC32a3c49700934481addd5ce1659f04d2";
string AuthToken = "";
var twilio = new TwilioRestClient(AccountSid, AuthToken);
var message = twilio.SendMessage("+14158141829", "+14159352345", "Jenny please?! I love you <3", "");
Console.WriteLine(message.Sid);
}
}
I am trying to make an outgoing call using Twilio and C#.
I gave the (fromnumber, tonumber, twiliodemourl) as 3 parameters for initiate
outbound call.Then it is working with default twilio demo voice content.
Now i need to customize the voice content attribute and some other attributes
every time i trigger the initiate outbound call method
I have gone through Twilio docs i did not find any good option for customize the
content dynamically from the code using C# every time i send the request.
My client application running periodically to verify for any new messages and then
trigger initiateoutboundcall.
I don't have any custom URL to post any new XML which voice is looking for in 3rd
parameter of initiateOutBoundCall.
So is it required a external domain URL to customize the voice content dynamically from code?
If no please provide the options/sample i have to do it from C# console application.
I tried to use the twimlets.com to echo the custom text to speak in the call.
For text change it is working fine with custom text. But i am not sure whether twimlets.com/echo can be used for production use? Please confirm. Twimlets is not supporting some of the features which i am looking for like Gather input
like IVR message for outbound call.
Using Twilio Voice and C# client:
Voice Request using Twilio C# client?
Dial the number with custom voice content(). If user not responds leave a
voice mail with the custom voice content().
Dial the number with custom voice content (). If user responds, after reading
the message need to provide options like:
press 1 for repeat the same voice message.
press 2 to confirm the action on the message.
press 3 to send SMS for the voice message.
Need to get the response for each voice call / message?
For the sms it send i am getting response as "queued" instead of message sent.
Based on the SMS sent successfully or not i need to update some flag.
So how i can get the SMS reponse as "sent".
SMSMessage sms = twilio.SendSmsMessage(sFromNumber, sToNumber, sMessage);
Console.WriteLine("SMS Status::::::" + sms.Status);
Similarly I need the reponse for voice call once the call is ring id done.
But it is giving "queued".
var call = twilio.InitiateOutboundCall(sFromNumber,sToNumber, url);
Console.WriteLine("Call Status" + call.Status);
So please provide me options for doing it using Twilio.
It would be great if you provide any sample example using C#.
Twilio evangelist here.
You do need some kind of public URL that Twilio can make an HTTP request to once the outbound call is answered. This is how Twilio gets the instructions it needs in order to proceed with the live, in-progress call.
As you noted there are a number of free options for hosting static TwiML content. Twimlets is one. Twimlbin.com is another. Both services are free and great places to at least get started prototyping or setting up a simple MVP of your application, but bear in mind that if you expect a large amount of traffic or you need to build something with your own custom logic in it you'll probably want to move to something else.
That something else could be your own website hosted as as Azure Website (which you can also get for free). Moving to your own website also means that you can scale it as needed and you can start serving up dynamically generated TwiML instead of just being limited to dynamic TwiML as you basically are with Twimlets or Twimlbin.
If you want to process input from <Gather> and none of the Twimlets meet your needs, then you will likely need to look at the Azure option (or some kind of hosted website, doesn't have to be Azure). This will let you build your own custom logic in order to process the callers input and dynamically generate a TwiML response based on that logic.
Twilio provides helper libraries for TwiML generation and for building Twilio apps using ASP.NET MVC, which you can get from NuGet.
Lets say you want to go down the road of building you own custom Twilio app using ASP.NET MVC and hosting it using an Azure Website. In that scenario, using our helper libraries you could build an action method in your controller that returns the TwiML with the <Say> and <Gather> verbs. Something like:
var response = new TwilioResponse();
response.Say("Hello World");
response.BeginGather(new { action="http://example.azurewebsites.com/gather/" } );
response.EndGather();
You would provide the URL that executes that action method as the third parameter in the initiaizeOutboundCall method eg:
client.IntializeOutboundCall(FROM, TO, "http://example.azurewebsites.net");
Once the user enters their input, Twilio will request the URL you specified in the <Gather> verbs action parameter passing you an extra HTTP parameter named Digits, which you can grab in your action method and use in your app logic:
public void Gather(string Digits) {
var response = new TwilioResponse();
response.Say("You pressed " + Digits);
return TwiML(response);
}
To get the status of a phone call or an SMS, you can include use the statuscallback parameter:
SMS: var result = client.SendMessage(FROM, TO, BODY, "http://example.azurewebsites.net/status");
Voice: var result = client.InitiateOutboundCall(FROM, TO, VOICEURL, "http://example.azurewebsites.net/status");
Twilio will make HTTP request to the statusCallback URL's once the final status of the message or call is reached.
Hope that helps.
As of version 5.32 of the C# SDK, you can pass a dynamic twiml string into the CallResource.Update() method like so:
CallResource.Update(
twiml: "<Response><Say>Custom Message Here</Say></Response>"
pathSid: call.Sid);
Or even:
string customMessage = "<Response><Say>Custom Message Here</Say></Response>"
CallResource.Update(
twiml: customMessage,
pathSid: call.Sid);
I'm using Google's .NET Client Library to read email on my gmail account.
But things are not very clear for me.
I'm trying to retrieve Atom feeds with this code.
FeedQuery query = new FeedQuery();
Service service = new Service("mail", "app-MailChecker-1");
service.setUserCredentials(Username, Password);
query.Uri = new Uri("https://mail.google.com/mail/feed/atom");
AtomFeed feed = service.Query(query);
It gives me a simple exception: can't retrieve feed.
My priority is to accomplish this using Google's .NET Client Library
but other options will be helpful as well.
Additional information: this method works for Google Calendar without a problem.
If you read Google's FAQ about the Google Data Protocol you'll see that it has no data API for GMail.
http://code.google.com/intl/nl-NL/apis/gdata/faq.html#GmailAtomFeed
To quote:
Does Gmail have a Data API?
No, but you can use Gmail's Atom feed with AuthSub or OAuth to request
read-only access to a user's unread messages. The scope should be set
to https://mail.google.com/mail/feed/atom/. An example query would be:
GET https://mail.google.com/mail/feed/atom/
If you're interested in managing your mail, Gmail also has IMAP/POP
support.
I experimented with version 1.9.0.0 of the Google Data .NET Client Library myself. Don't see any references to GMail.
Here's one possible approach on how to retrieve the unread messages:
http://www.dotnetcurry.com/ShowArticle.aspx?ID=292
It's similar to what Christian suggested in his comment.