I suspect that one of the c# method is never called (because of if codintions); but the software is a client and it's distributed to 1000 users.
So I would like to call some remote API to log every time the method is accessed.
This kind of tracking has got a name? Is it possible to use Google Analytics through c# as a workaround?
It's pretty easy to achieve using Google Analytics.
Is there any way to post events to Google Analytics via server-side API?
A c# wrapper has already been provided:
https://gist.github.com/0liver/11229128
Related
I'm trying to figure out how to access MS Teams or Skype commands, which are listed here, Teams commands link from within c#. Is there any way this can be done?
I can execute the commands from powershell, by importing the teams or skype module, but I want to execute the commands from within c# instead and retrieve the result data in order to process it afterwards. Is there any documentation on the subject? Or maybe somebody has done this.
EDIT: For example, this is how I would run the command "Get-CsOnlineVoiceRoute" in powershell. Its a pseudocode
Import-Module SkypeOnlineConnector
$sfbSession = New-CsOnlineSession -SessionOption (some options)
Import-PSSession #sfbSession -AllowClobber
Get-CsOnlineVoiceRoute
In the answers bellow, the guys suggest that I can use the Microsoft Graph API to do this. But can somebody show me an example call. Maybe with the command im using. How can I get the same results using the API? Or is there any documentation about what ps command relates to what api calls?
What you are looking for is to use the Microsoft Graph API. The Microsoft Graph API is a RESTful API that enables you to access Microsoft Cloud service resources (e.g. even Teams). The MicrosoftTeamsPowerShell PowerShell module is simply a convenient wrapper making API calls on your behalf for you. Since C# can also make RESTful API calls, I recommend accessing the API directly for the most seamless user experience.
Accessing and configuring Microsoft Graph API is beyond the scope of SO, and I recommend going over their Graph Quick Start page to go over some basic code samples to get you started. If you can do this type of request:
{HTTP method} https://graph.microsoft.com/{version}/{resource}?{query-parameters}
Then you are all set up to access the API. The specific API section/resource you are interested in is the Microsoft Graph Teams API. The Microsoft documentation has more info on what you might be trying to achieve.
Other things to keep in mind is, if you can't seem to do something, that while v1.0 of the API is "Production" live, the beta version has many more additional resources available and may have a feature you need. (esp. when dealing with Azure Active Directory, there are certain things that can only be done with the beta version of the API). I find the Graph Explorer to be extremely helpful in finding out exactly what type of requests I need to make before I start coding.
You can use the Graph API call to call teams commands. Could you please check this sample?
Im using gtm.js to track some data into my site. This is front-end part. But I need to create server-side logic(.NET) to track my data. I can;t find any information on the Google guide about server-side. Please, tell me is this possible and maybe some examples. Thanks
GTM is a client-side Javascript injector. It's also not a tracking/analytics software, although it can be used to deploy such software.
If you want to track information to Google Analytics you can use the measurement protocol, a language agnostic protocol that can be used in any language that can issue http requests.
If you need to trigger other tags from the server a service like https://segment.com/ might help you (comes for a fee. I am not affiliated or anything).
Update Feb 2020: Google has announced a closed beta for server-side tracking, where you run a container in a cloud environment that then distributes the requests. Simo Ahava has a little info in his twitter feed: https://twitter.com/SimoAhava/status/1222459714614841346. This is not yet a production feature.
GTM runs only on the front end (meaning on the client's browser side). But, as I can't determine based on your question what you are trying to accomplish, I can say that you can put some information in the dataLayer in the backend and then use that info on the frontend and manipulate with it in the GTM, before sending it further to any other scripts or tracking engines.
I have a C# Azure Web API backend where data is retrieved from a front-end Ionic Mobile App (which is basically an Angular App)
The authorization of users is done via Ionic's cloud service, so they handle the heavy lifting of registering users via FB, Twitter, basic (username/password).
My question is, when I go to call services from my backend API, how can I make sure someone just doesn't read a hardcoded username/password inside of the internal javascript code to access the backend data?
I know it's pretty far fetched, but is there anyway for the API to know the request is actually coming from the app (Android and iOS) and not just from someone trying to insert data and comments from a web browser that is unauthorized?
Since you're calling the API from JavaScript that is available for end users, you can assume that your JavaScript and all the logic/credentials contained within are accessible to all.
There are fairly secure ways around this, and FB/Twitter and their ilk have implemented it (using OAuth). Essentially, on passing credentials to the API, a token is generated, which is then used for subsequent calls to the API instead of the credentials.
You can avoid people randomly firing off 'unauthorized' requests using nonces which are generated when you render the form, and can be used only once to submit the form in question. You can then time-limit the validity of the nonce on the API end. Unfortunately, it's not foolproof, but this will limit the damage of any sort of 'brute-force' attack that you might get.
Again, with any shared 'secret' (that would guarantee the origin of requests), you have to assume that anyone with enough willpower will be able to extract it from apps, thus any method you implement here will be 100% foolproof. Probably the best you can do is have a shared secret generated for each user on each device.
Short answer: you can't.
Long answer: you can (and must) validate the behaviour of a client but not the client itself.
For example we can take a look on Pokemon Go: after a few hours there were bots able to play, after a couple of weeks Niantic started assuming Machine Learning software engineer and encrypt its API using unknown6 algorithm for stopping the bots, but after a few days of hard working the bots came again online.
You can use all the secure method of this universe (whit an high expense) but if someone (that have good knowledge of software engineering) want emulate your client at the end I will reach his objective
how do I send Twitter updates in C# but without the need of OAuth?
The reason is, is because I heard that Twitter limits how many Tweets one can send, and I am planning to send a lot.
The officially supported means of sending a tweet via a third party application is by using the REST API twitter provides. This does require clients to use OAuth to authenticate.
If you don't want to deal with the API directly you might consider using a library which wraps the official API. I can't personally recommend any particular library as I have not used a Twitter library in a long while, however Twitter does provide a list of API implementations which may interest you.
It is possible that one could use the WebBrowser control to interface with twitter by website form fields with values passed to your application through your application's user interface.
Doing this is not advised for the following reasons:
It's officially unsupported and against Twitter's terms of use. This method depends on your application parsing the twitter user interface in order to find and populate form feilds. The names of these feilds may change at any tine without notice.
It will not circumvent the rate limiting. Twitter's rate limiting is enforced at the server side and the web interface is not likely to be immune to this rate limiting.
I'd like to write a console program in C# that posts a Tweet to Twitter. I've never used the Twitter APIs before and don't know anything about how their authentication works. I found an API library called Twitterizer, but it seems geared towards web applications and wants the user to logon with a web browser. All the API docs on Twitter's website seems geared around this scenario as well.
Is it possible to access the Twitter APIs using a console app with no web browser access? I'm perfectly fine hard coding in the name and password for the Twitter user I want to post under as well. Thanks!
Mike
You'll need to use OAuth for authenticating in twitter.
Then use regular HTTP Request to use the twitter JSON-based API.
Here you can find a good article about OAuth, Twitter and console applications.
Also take a loot at linq2twitter lib. From it's documentation;
The Twitter API is built using
Representable State Transfer (REST).
Wikipaedia defines REST as "...a style
of software architecture for
distributed hypermedia systems...",
but I'm going to be so bold as to try
to simplify what that means. In
practice, REST is a Web service
protocol built upon Hypertext Transfer
Protocol (HTTP). You use the REST Web
service by making an HTTP call with a
URL and getting text back in some
form, which is often XML or JSON. So,
if you were to write code that made an
HTTP request with the following URL:
http://api.twitter.com/1/statuses/public_timeline.xml
You would get back an XML document
with all of the Twitter statuses from
the public timeline, which is a
snapshot in time of the last 20 tweets
at the time of your request. Go ahead
and open your browser, copy and paste
the URL above into the address bar,
and see what you get back.
I couldn't find any decent information on the web on how to do this, so I decided to write my own blog post with all the details.. Enjoy!
http://blog.kitchenpc.com/2011/01/22/rise-of-the-twitterbot/
of course you can use anything to connect to Twitter via RESTful api.
you should use oauth, and set up your application in http://dev.twitter.com, then you should read all articles listed in documents, you must specify your app as Client but not Browser so user input a number to get through authentication.
you can use many libraries so that you can save your time, all are listed in the documents
and be CAREFUL, you should not use Twitter's own api console which is buggy (as i know parameters somtimes can't be parsed), you should use APIgee instead which is powerful and stable.
if you want use basic authentication, you should use api proxy (one famous is twip), if you just need only one single C# apps, you must code by yourself:
you should use given username and password to login twitter, parse cookies passed
use normal oauth to get temporaly access token url.
use cookies got from step 1, emulates form submit to allow your apps, capture PIN code
use pin code to finish oauth.
MOST IMPORTANT, you must store access token in client's machine so next time you can bypass above steps
Just wrote a Twitter Bot in C#. This is currently posting tweets to #valuetraderteam.
https://gist.github.com/sdesalas/c82b92200816ecc83af1
The API component in the GIST below is less than 500 lines, only dependency is Json.NET, you'll need to download the latest DLL for either x64 or x86 (depending on what platform you are targetting) and include as a reference in your project.
There is an example at the bottom of the page of how you can make a tweet from a console application
Hopefully this is useful to some other people out there.