how to use pragrammable chat of twilio in c# - c#

can enyone help me out to undersatnd this Here's a link! how to use in c#
i want to know how to use it
how to use pragrammable chat of twilio in c#

var client = new TwilioIpMessagingClient(accountSid, authToken);
Message message = client.CreateMessage(serviceSid, channelSid, memberSid, body);
Console.WriteLine(message);
https://www.twilio.com/docs/api/chat/rest/messages#action-create

Twilio developer evangelist here.
There is a full tutorial for using Twilio Programmable Chat from C# right here.
You might also find that the Chat fundamentals documentation will help. The key is that you need to run a server which you can use to generate an access token for your users so that they can access the Chat service. Once you have done that, you can build the rest of the application in the front end. You can also perform actions from C# using the REST API.

Related

Issue with Twitter API possibly Tweetinvi (Forbidden)

I've been trying for days on this and think that the issue is somewhere with my developer account but thought I'd ask for advice here first before digging in there.
I have followed the documentation and multiple tutorials and this should work it seems but no matter what call I make using Tweetinvi to Twitter I get "Forbidden" which when looking at the twitter codes means my authorization is correct but that I am asking for something that I don't have access to, but I am just trying to send a test tweet to see if the program works, which according to Twitter's documentation I should have full access to. Here's the code that I took from Tweetinvi's Tutorial on how to make a "Hello World" tweet but it just doesn't work cuz it returns "Forbidden".
static async Task Main(string[] args)
{
var userClient = new TwitterClient("APIKey", "sAPIKey", "AccessToken", "sAccessToken");
var tweet = await userClient.Tweets.PublishTweetAsync("This is a test tweet");
Console.WriteLine(tweet);
}
It's not just the send tweet function either, if I try to pull any information at all it says it's forbidden so I feel the issue is on Twitter side not my code but I am just trying to learn it as a hobby and have no idea. Just was told Tweetinvi would make everything take 5 minutes and now I am at three days of trying to figure this out. Any help in figuring this out would be nice and greatly appreciated.
Twitter's latest API release [Nov 15th 2021] has an entry level of access called "Essential" that provides access to the v2 API, because this should be the base for most new apps. If you need access to v2 and also to the legacy v1.1 APIs in the same app, you will need "Elevated" access, which is also available for free. The PublishTweetAsync method you are calling in the code in this question is trying to hit the v1.1 Tweet statuses/update endpoint, so your app will need Elevated access in order to make it work.

Can I connect a kotlin android app to a .net5 REST API

So I was thinking about learning about app development for android. I know you use kotlin however, I also want to start working with .NET and C# is there a possibility for my first app that I create a basic login and register form in the app using Kotlin and connect it to a .NET REST API? Is that a thing I am sure you are just using the URL for the API call?
Sure! Using Retrofit, the Android app could be connected to the RESTful APIs that is available using the latest technology by Microsoft and the open source community; ASP.NET Core Web API 5.
A complete guide to do so:
http://codingsonata.com/a-complete-tutorial-to-connect-android-with-asp-net-core-web-api/
yes it is possible, there are plenty of libraries that are able to help you with that, like Retrofit or Volley
Yes. It's a very common way to consume API for data processing purposes in android-based applications.
If you have learnt on how to consume API with Android Application (built using JAVA), it's pretty much the same.
if you have never used JAVA to create android applications that consume API, don't worry because the process you need to do is very simple, moreover there are already many collections of libraries that you can use for this purpose. You can try to look on several library such as Retrofit and OkHttp.
Let me show you a a simple example of using OkHttp to pass data from android to API. This simple example is quoted from this article
private val client = OkHttpClient()
fun run() {
val formBody = FormBody.Builder()
.add("search", "Jurassic Park") /*The parameters*/
.build()
val request = Request.Builder()
.url("https://en.wikipedia.org/w/index.php") /*API URL*/
.post(formBody)
.build()
client.newCall(request).execute().use { response ->
if (!response.isSuccessful) throw IOException("Unexpected code $response")
println(response.body!!.string())
}
}
I hope this answer can be helpful for you. If you need more assistance, don't hesitate to contact.
If you are using API, you use URL and model of your data.
I recommend Retrofit as a library for connecting to any API. A good example is here, check out this and I think you will be well prepared to write Kotlin code.
Firstly, you need to define retrofit client, with your URL:
retrofit = new Retrofit.Builder()
.baseUrl("https://reqres.in")
.addConverterFactory(GsonConverterFactory.create())
.client(client)
.build();
then you need to map your API as an interface, for example if you have an endpoint https://reqres.in/api/users? you must define them like this:
#GET("/api/users?")
Call<UserList> doGetUserList(#Query("page") String page);
For creating .NET Core API, especially with user registration you must check some of tutorials, I recommend to be familiar with EF Identity (other).

Will making call or sms requests via the Twilio C# libraries always use HTTPS?

So I have some code that makes a call to the Twilio web API via the Twilio supplied C#.Net Libraries.
private static void SendSMS(Shift_Offer so, Callout co, testdb2Entities5 db)
{
co.status = CalloutStatus.inprogress;
string ShMessage = getShiftMessage(so, co, db);
so.offer_timestamp = DateTime.Now;
string ServiceSID = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
var message = MessageResource.Create
(
body: ShMessage,
messagingServiceSid: ServiceSID,
to: new Twilio.Types.PhoneNumber(RCHStringHelpers.formatPhoneNumber(so.employee_phone_number)),
statusCallback: new Uri(TwilioCallBotController.SMSCallBackURL)
);
so.status = message.Status.ToString();
so.twillio_sid = message.Sid;
db.SaveChanges();
}
When I send this message request to the through the C# libraries, will it make the request using HTTPS? I'm concerned about sending the SID in plaintext.
Twilio developer evangelist here.
The API is only available over https at the base URL https://api.twilio.com. Also, all the officialy Twilio libraries, including the C# one, are setup to use https by default.
I've developed a Twilio integration for Dell.
They have some source code available here:
https://github.com/twilio/twilio-csharp
You can see there that they are using HTTP
https://github.com/twilio/twilio-csharp/blob/master/src/Twilio/Http/SystemNetHttpClient.cs.
Here at Dell, I needed to create my own Twilio implementation based on their REST API because of security concerns using HTTP.
Therefore, I highly recommend you to develop by yourself and make sure to use the HTTPS protocol.

How do I create a webhook for sendgrid in c#?

I am new to using Sendgrid emails using c# .Net library. Our requirements wants us to track the status of the email like Delivered/Went to Spam/Client opened/reported as spam etc., By looking at the documentations and answers from other users to my previous questions its my understanding that there is no direct way to track the status of the email (like result object).
It would be really helpful if someone can point me to some example/sample codes or documentation/implementation in C# for the following
1) Adding unique parameters while sending the email using send grid API. Can I use a Guid string as my argument
I am assuming what I am doing below is correct.
var myMessage = new SendGridMessage();
var identifiers = new Dictionary<String, String>();
identifiers["Email_ID"] = "Email_ID";
identifiers["Email_Key"] = "9ebccd0d-67c0-4c28-bbf3-83d5bb69f098";
myMessage.AddUniqueArgs(identifiers);
2) How to use event webhooks to get the status with the unique argument that I used above from the http_post so that I can associate an email to the status. Any sample code , documentation in c# or an overall idea of how this works will get me started on this.
Appreciate your time and answers.
Sending emails via SendGrid is easier from C# using the official library that SendGrid provides. From your code example, it looks like you may already be using this - good job.
The unique argument should work as long as its been stringified, and you're not trying to pass an object to myMessage.AddUniqueArgs.
The Event Webhook will send a JSON packet to any URL that you specify. If you have included unique arguments in an email that you send out via SendGrid then these are automatically added to each event response you get back from the webhook - you don't need to turn anything else on to get the arguments as well.
There is an example of this call and the resulting response in the SendGrid Documentation.
SendGrid has an Event Webhook which posts events related to your email
activity to a URL of your choice. This is an easily deployable
solution that allows for customers to easiy get up and running
processing (parse and save) their event webhooks.
This is docker-based solution which can be deployed on cloud services
like Heroku out of the box.
https://github.com/sendgrid/sendgrid-csharp/tree/main/examples/eventwebhook/consumer

What are the available functions to send notifications to a Facebook user?

Currently I am using Codeplex's Facebook Developer Toolkit version 2 for my ASP.net Facebook application. I would like to be able to send notifications to a user's Inbox or wall of the application and was wondering what are the available functions to do that? If not in the API, then please provide example functions from the main Facebook library. This will help immensely. Thanks!
After a brief search I found an example of sending notifications using the toolkit:
facebook.Components.FacebookService fs
= new facebook.Components.FacebookService();
fs.ApplicationKey =
ConfigurationManager.AppSettings["APIKey"];
fs.Secret =
ConfigurationManager.AppSettings["Secret"];
string sessionKey =
dict["facebook_session_key"];
fs.SessionKey = sessionKey; fs.uid =
long.Parse(member.FacebookId);
fs.notifications.send(member.FacebookId,
"notification message");
(from: http://facebooktoolkit.codeplex.com/Thread/View.aspx?ThreadId=49876)
After looking through the Codeplex source it's clear that this sends a user-to-user notification, and therefore requires an active user session of the sender.
Codeplex does not appear to support app-to-user notifications which do not require a session, but adding this feature would be trivial. Add a type variable to the send method and set it accordingly based on the API documentation here: http://wiki.developers.facebook.com/index.php/Notifications.send
The source code for the notifications.send method in the Codeplex Developer Toolkit is here:
http://facebooktoolkit.codeplex.com/SourceControl/changeset/view/28656#233852
Please keep in mind that the Codeplex developer toolkit source code has not been updated in over 3 months. This means that it does not support many new Facebook API features and changes. You may want to browse the client library wiki page to find a library that is more up to date: http://wiki.developers.facebook.com/index.php/Client_Libraries

Categories