Getting livestreams from YouTube channel - c#

I am trying to keep track of the livestream viewers of a specific channel.
This is no problem when I have got the stream ID and use it manually.
However I want my program to be able to track upcoming livestream automatically. So I want to get the livestream ID from the channel for the next upcoming livestream. I have been looking through the documentation from the API, but I couldn't find anything.
What API call do I need to make?

You cannot get the liveBroadcast or liveStream object that does not belong to the user or channel you are authenticated as. The list endpoint for each object requires you to authenticate as your own channel/user to retrieve your own live events only.
If you want to retrieve information on another channel's current live broadcasts, you have to use the standard Search/list endpoint:
part -> snippet
channelId -> [channelId of the channel/user with the live event]
eventType -> live
type -> video (required when setting eventType to live)
HTTP GET https://www.googleapis.com/youtube/v3/search?part=snippet&channelId={channelId}&eventType=live&type=video&key={YOUR_API_KEY}

Related

How to retrieve a payment method on the client side?

We are running an App with a Angular/Typescript frontend and a .NET backend, using Stripe Elements and Stripe.NET respectively.
We are currently using the "Sources" API.
The frontend can create sources, the backend saves them to our specific users. When you open the frontend again, the backend sends a list of source ids. The frontend then collects the data it needs to display those sources directly from Stripe so the user can pick one of his saved sources to pay and does not have to enter all the data again.
Enter the Payment Method / Payment Intend API.
Due to EU regulations Stripe has a new API that requires us to create cards no longer as "source" but as a "PaymentMethod". So I implemented that in the backend, opened the frontend in my IDE, updated the #types/stripe-v3 package and found the new payment intent API.
The only thing missing: I cannot figure out how the frontend is to access the payment method data, once created. I can create it. Send it to the backend. The backend can retrieve it. Send back the ID to the frontend... and now what? How to display the payment methods available?
I had expected a stripe.retrievePaymentMethod() as there is a stripe.retrieveSource(). But no such luck.
The only option I currently see to present the user with a list of existing payment methods is getting this info on the backend and piping it all, class by class, property by property to the client. Basically copying every single data class stripe has into our own backend REST definition. That cannot be right.
What am I missing? Why is there no stripe.retrievePaymentMethod() on the frontend? Did I not understand some fundamental facts about what those APIs should do?
After contacting Stripe directly, it was confirmed that that's just the way it is:
I think it's just an oversight that we didn't add one.
There are similar functions in the mobile SDK so I don't see why we shouldn't have it
There are no immediate plans to add the functionality back in in the very near future,
so as a workaround, I will tunnel all the data through our backend(s).
If I understand as well, I think your problem is following and the sequence of that. I hope this helps you.
I have implemented a payment gateway like ccAvenue with DotNet and angular, in my case, I send the data to the server, and from the server, I tried to redirect to the payment gateway, but APIs return some result, and the result can not be redirected.
So I created a web-form with implementation, I redirected my app to web-forms page and from there I called the ccAvenue page, and in the response URL, I send the response page of webforms only and after saving the response I redirected to my angular app.
Here is workaround if you want to process 3Dsecure cards and still support other methods like SEPA.
You could attach both, confirmed PaymentIntent (payment method) or Source to the Customer object.
On your frontend you could implement both (StripeElements with client secret for 3Dsecure cards) and IBAN element for SEPA.
I could provide my code example how I save payment intent to the customer. It's in PHP, but for other languages logic should be the same.
Assuming that our client already confirmed PaymentIntent and we have it's id:
$intent = \Stripe\PaymentIntent::retrieve($stripe_intent_id);
$payment_method = \Stripe\PaymentMethod::retrieve($intent->payment_method);
$stripe_customer = Stripe\Customer::create([
'payment_method' => $intent->payment_method,
]);
In case you've already created Customer object before you could use attach method:
$payment_method->attach(['customer' => 'cus_FTkGe4lv5LfyI0']);
Then you'll be able to charge using Customer object PaymentMethod or Source;
I didn't try to attach both methods to the same customer object (we only allow customer to have one payment option at the same time), but it should work. Let me know if it works for you.

Get Skype voice notes in a bot

I am developing a bot in C# for Skype and my problem is that I would like to transform the voice notes that can be sent by the phone (with the icon of the microphone) in text and I can't get that audio.
In the properties of the activity.attachment that I receive I have seen the following:
ContentType: audio
Content:
ContentURL: https://smba.trafficmanager.net/apis/v3/attachments/0-weu-d9-734cab9e78c28a1619a39ce8c69342d1/views/original
Name: 2-audioMessage.m4a
Properties: {}
ThumbnailUrl: https://smba.trafficmanager.net/apis/v3/attachments/0-weu-d9-734cab9e78c28a1619a39ce8c69342d1/views/thumbnail
it seems that it is saved in the state.
Is there any solution to get the audio file for later send it to a text to speech API?
I would not like to use audio calls because at the moment it's very complicated to implement.
Thanks.
I am assuming that you must have done the following setting to use your callback URL to convert it into text:
1) Register you bot in Microsoft Bot Framework Portal. Please refer to this for the instructions. Once you complete the registration, update the Bot's Web.config file with the registered config values (Bot Id, MicrosoftAppId and MicrosoftAppPassword).
2) Enable the Skype Channel and update the settings by enabling 1:1 audio cals and updating the Calling Webhook to be https:://{your domain}/api/calling/call. Refer to this for more information on how to configure channels.
3) Update the Microsoft.Bot.Builder.Calling.CallbackUrl setting of the Bot's Web.config file with the callback route https://{yourdomain}/api/calling/callback.
4) Subscribe to the Microsoft Cognitive Services Bing Speech API here to get a key to use the API. Update the MicrosoftSpeechApiKey setting of the Bot's Web.config with the obtained key.
In the following repo , you can find the complete implementation forthe same.
https://github.com/jj116/skype-CallingBot/blob/ac913ab484fcdaf1933bfd230b60041ab10ff3f1/IVRBot.cs
Hope it helps.

How can I have my bot start in a different dialog depending on user

Basically, I want to have my bot on different pages using iframes and Bot Framework Web Chat.
Depending on what page the user opens the bot, a different dialog is called.
Without Direct Line, this is as simple as adding a query parameter to api/messages and adjust the controller. But with Direct Line, I can only specify one endpoint in the portal.
I tried to change user.id in the JavaScript BotChat.App call to a different identifier and then select the correct dialog in my MessagesController based on that.
BUT: my custom id doesn't seem to be available as early as the activity "ConversationUpdate" occures where I send my welcome message. I need to send a dialog-specific welcome message though (so I need to navigate there as soon as possible and not only when the user types his first message).
Take a look at the backchannel. In your scenario you can pass a parameter from the Javascript via the back channel to set some value in UserData. Now your parameter will exist in state (in this case the IDataBag UserData) when your user first hits the bot.
Here is a C# sample of a 2-way backchannel
another C# sample using a 1 way backchannel

Generating Google Analytics from a C# Application

I would like to be able to generate Google analytics data that will show me number of startups of my application but also the time it tool for each starup and the average time for all startups. Something like:
Startups 1296
Startup Times
40ms
27ms
128ms
700ms
42ms
82ms
...
...
127ms (Average)
I know it is possible to get the Startups but not sure if it is possible to also get Startup Times. Is it possible to do this and how from a C# desktop application?
I am developing a lib called gappalytics, it allows you to log analytics events for desktop apps. Link to package nuget.org/Gappalytics.
Usage sample: github.org/gapalytics
As long as you can sent http request in realtime (or a narrowly defined offset window) you can use the measurement protocol. I don't think there is a C# client library, but this is basically just a http request with the parameters and and such its language agnostic.
There are a few required parameters - the protocol version (always v1 for now), Google Account ID, a unique Client ID per user or device and a hit type (pageview, screen, event, transaction etc.). Also depending on the hit type you need additional parameters (document location/page title, event category/action/label etc.).
There is a parameter reference with all possible fields, and you can construct hits for testing via the hit builder.
Google Analytics has a "user timings" hit type (basically you pass a description and a duration in microseconds), so the report from your example should be very easily doable.
I don't know C#, but I'm reasonably certain is has a way to format a string as an url with parameters and send an http request, and in the end that's really all you need for data collection with GA.

Getting the chat ID from call ID with the Skype API

I'm writing a simple conference host in C# for the Skype API. When the program is notified that a call has ended, I want it to send the "/golive" command to the group chat associated with the call that just ended. I can do everything except retrieve the chat ID from the call, or even vice versa.
It appears from the API documentation, that there is no link between the chat and the call, but this makes no sense as you can only have one call per chat, and Skype gives you a "join call" button at the top of the chat, so Skype MUST link between the Chat and the call. Any ideas how to get at that information?
go to the group chat profile, copy conversation link -> it will look like skype?chat&blob=
delete that part then the api command is CHAT CREATEUSINGBLOB
after that you get a #thisisyourchatid and you just chat to that address (including the #)
In addition to previous answer you can use "/get uri" or "/get blob" chat command in a group chat to get blob.

Categories

Resources