As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
We are about to create an API so that our customers can connect to us, subscribe to a service and then consume that service. what is the best way to implement this? we work in C#, .NET. We want something like this:
we will provide a username and password to our customer to connect with our API. (how to implement this, using database?)?
after successful connection , customer will subscribe to our service. (how to check that customer is already connected? )
after subscription customer can calls API methods.
kindly tell me the best way.
Have you ever look servicestack ? It's awesome ,totally DTO based and very easy to create API for .net
Please look out my blog post about that
Check this thread for authentication options in ServiceStack.
https://groups.google.com/d/topic/servicestack/U3XH9h7T4K0/discussion
Look at example here
A simple solution is to supply a Login method, your customers must call this one with username and password before consume the service, you can issue a token to the client once username/password validated, usually stored in a database; then the client can call your API method with the token attached for each request so you can check whether the client has called Login method or not; the token will be destroyed after the client finished using service by either providing a Logout method or setting up a expire time for each token.
This is for your consideration. About "best" way, I think there's no such one way best for all situation. You will find the best way for you.
This might inspire you or prove useful.
http://visualstudiogallery.msdn.microsoft.com/b1d767d9-d6bf-41ee-89a8-313d338e63b6
There are also some links in there that talk about using API keys so you can control who's using your api why that's essential.
Related
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I am attempting to create a natural language processing program in which I must be able to translate words and sentences as well as getting their parts of speech. I have heard that you can implement Google Translate API in your program, but have worked on it with no luck for the past 2 weeks. I have tried looking at other translation services such as this, but with my very limited background in C#, I can not make much out of the article. Can anybody provide me with a simple walk through, I would like to learn what I am doing so I can further my knowledge of C#, that I can use to be able to accomplish my goal. It does not have to be the Google API, but any help is greatly appreciated!
Two mainstream options are
the Microsoft API, this is free to a certain limit
the Google API is a paid service
An cheap and dirty option would be to call the Google translate directly via a HTTP request (in another words screen scrape the Google translate page) with the new ASP.NET Web API its quite easy to do HTTP requests elegantly. eg: to translate the English phrase "test this" from English to French you need the below URL.
http://translate.google.com/#en/fr/test%20this
Here is the asp.net web api resource.
I don't think you can use the code from the article in the way you intend. Since it's writing Bing took over altavista and changed what the destination of the url is, and this code didn't do any translation itself anyway, it just passes it off to babelfish to chew on but not in a way that is stable long term.
I'd go with google translate https://developers.google.com/translate/v2/getting_started
Best of luck!
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I am currently developing a ASP.NET MVC4 website, and I would like to know whats the best practices storing the logged-on user's data (include privileges) and authorize the user securely, being able to access this data in both my views and controllers.
One thing to important mention - I am NOT using the Membership class (I've saw that its an overhead for me to use it, and I would like to implement the exact things I need and learn from the process).
The only way I thought to do it is storing all the data inside the session object, and having a wrapper to the session object (static class) and use it like SessionManager.IsLoggedIn(), SessionManager.GetUserPriviliges() or simply creating a method that returns hard-typed UserSessionData SessionManager.GetSessionData() that contains all the data required.
This is one way to use it in both controllers and views. Shall I derive from Controller and create a RolesController which stores UserSessionData so I won't need to call it again and again in my controllers?
I guess I won't be able to use the common AuthorizedAttribute so I will have to implement it by using the session wrapper (Is it safe to use only the session data? since I am not using the 'official' authorization method and therefore I don't really know how it should be implemented).
As you see, I have an idea but since its my first time doing it I would like to learn about the best practices and the way it should be done correctly. I will be thankful if you will explain your answers since I want to get the complete idea and I haven't done it before in MVC.
Thanks in advance!
It is not safe to do anything you've described. Static classis are dangerous in asp.net because they are not multi-user safe. Static classes are shared between all threads in the app, including threads running other users requests.
Just use the default mamebership until you know what you're doing. You will just be creating a vulnerable architecture otherwise.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
I am going to develop a client side application such a way that my client should able to receive fixed line calls through a computer and the application which is running on client's machine able to save the caller's number to a remote database.
Is there any application currently available for this? What are the requirements should I have before begin the project?
You will probably have to setup a PBX system in your client computer if you are wishing to connect phone line to the computer. You'll have to buy a Terminal and input a SIM to it. Or you could buy a SIP trunk from a Service provider and you'll able to take calls via the Internet.
If you are connecting with Java you'll have to use Asterisk PBX API and some configurations are necessary inside the PBX system. For logging calls to the remote database would be easier since Asterisk can be configured to store Calls to a MYSQL database.
As for more customization of this process would require a remote database and manual logging.
If you are going to use the Asterisk API you will find it quite helpful since you can take calls directly using it. But if it's for a simple use you can go ahead and install a Softphone - something like X-Lite or Linphone.
You can refer this tutorial for more use of Asterisk Java.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I am currently trying to write some code to consumer the user stream from the Twitter streaming API:
http://dev.twitter.com/pages/user_streams
I am struggling to connect to it using basic auth and assume (the docs don't say) that OAuth is required.
However I cannot find a Twitter .NET library that supports streaming and OAuth (actually, haven't found any with decent samples/docs on consuming the streaming API).
Does anyone know of any? Currently I have written my own code to consume the sample stream using C# and dynamic but really don't want to have to implement OAuth (people say its complex).
Edit:
Although, I have been able to get an access token and access token secret via the TweetSharp library fine, I have no clue on how to generate the required headers/implement oauth, which could be another option I guess rather than a full library.
Short version:
Looking for a library that supports streaming API and OAuth
Advise on implementing OAuth manually
As I explained in this post Consuming twitter stream API, Tweetinvi API provides easy to configure Streaming API access.
You can download it here : http://tweetinvi.codeplex.com/
A Stream class exist and will enable you to easily implement a delegate to read the content coming from Twitter.
The class has been tested on real-life projects and is able to retrieve millions of tweets per day.
I am one of the developer working on the project.
Check Shannon Whitley post:
Twitter oAuth with .NET
I've used the TweetSharp library in the past, which supports OAuth.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 12 years ago.
I'm amazed that years over years IT pretend to simplify communication or software design and a few years later it declare it was over-engineered. EJB, SOAP, so looking at all the WCF stuffs do we as users (not as Microsoft or IBM who need to sell new stuffs) really need it ?
Update: this is a concrete example
http://www.go4answers.com/Example/expert-interoperability-issues-ws-736.aspx
The guy knows how to call a server with WS-Security using old soap and in WCF it seems it doesn't really help and worst it seems even more complicated as it is said:
"WCF has still some limitation - not all WS-Security configuration are possible without custom development."
Nobody seems to be able to have found a solution.
So can people instead of mere opinions give concrete examples (with source code both in wcf and in soap or rest for comparison) of hard problems (and not easy problems) that can be solved by WCF more easily than can be with traditional soap ?
What I like about WCF is that it can be as simple or as complex as you want it to be. I also really appreciate the separation between contract and binding, where you can clearly define your operations and have the option of choosing which transport to use.
WCF is meant to make a developer's life easier. You can re-write the logic for a service, auto-wire multiple endpoints, and voila...your logic is available via SOAP, REST, Named Pipes, etc.
Unfortunately it's not as easy as it was all made to sound. Personally, though, I still find it a useful tool for re-using my code.
If you really want to jump on the bandwagon and say that REST/JSON is the only way to go...then WCF will definitely seem over-engineered. ASP.NET MVC does a great job at RESTful JSON services if you don't want to deal with the WCF overhead.
With 4.0, they've simplified configuration. I find it very easy to do this. But realize WCF is designed to make a lot of the internals of communication between services transparent. You don't care if its SOAP, REST, etc. All you do is write your service and "hook them up". COde for my services is exactly like I'd write normal code, with the exception of a couple of attributes added to the class and methods and some configuration (with 4.0, very simple imho)