Javascript that communicates with a Hosted API? - javascript

Basically I'm developing .NET API that allows a certain Javascript to access a Database through it. The database contains User Information and the API is the mediator between the client (running the javascript on their websites) and the database. The javascript simply gets the data from the DB and displays them.
My problem is, where do I host my API so that the client Javascripts can access it? What is this system called? I'm using Microsoft Azure SQL Databases to store the user information. How do I access my C# API from the client's javascripts? Do I need to host my API on Azure's API Hosting service? Very confused.
1) Client adds the Javascript and a HTML div to their website
2) The Javascript should access the API
3) API accesses the Database and gets the Data (Which is completed and it works)
4) Send the Data to the client and the javascript populates it
I just need to figure out how to make a connection between the API and the javascript on the client's website
Do I need to use THIS?

I would use ASP.NET Web.Api. It allows you to build a REST endpoint in C# that you can host on the Azure platform as well. You will be able to host it using the web sites features of Azure. Even though you want to build an API not a web site hosting it in a web site container will give you what you need:
Easy hosting solutions
Web endpoints for your client JavaScript to consume
C#.NET
Web endpoints close to your database. (Host them in the same data center)
Scalability
Monitoring
Ability to create a web site at the same address if you need to.
I haven't used Azure api management so I can't comment on that, but you will be able to get an ASP.NET Web.Api site up very quickly.

Related

Receive alerts to a multipage application using WebSockets

I have created one POC for alerts using WebSockets. Where I am using AWS Socket API gateway for server side implementation and WebSocket JS API in client side.
Now I need to integrate WebSockets with a multipage application and need to get alerts. But I can't use same websocket instance in all the web pages, I have to open different web sockets for each page. Now I want to set some unique identifier for all the open sockets such that all the web pages for the logged in user in a particular browser have the same socket id, So that it will reduce the overhead of storing so many socket ids against one user sessionid.
So I want to know if it is possible with WebSocket API in JS or any other API is available which I can use to achieve this MultiSocket with same socket id kind of implementation.

Azure Website - Query Azure Database with REST

I currently have a basic html/js/css web app being hosted on Microsoft Azure. What I need to do next is pull some data an Azure SQL database onto one of the pages using REST calls.
Does anyone know what steps I need to take in order to accomplish this?
I built my own Web API in VS 2015 for my database and deployed it to azure that way. See reference below:
http://www.infragistics.com/community/blogs/dhananjay_kumar/archive/2015/06/05/a-step-by-step-guide-to-working-with-the-asp-net-web-api-and-angularjs.aspx
Your question is too board. There are many ways can satisfy your requirement. Generally speaking, you need to build a backend service to connect to your SQL Database and provide REST APIs service.
On Azure, you can quickly acquire this via Web Apps or API Apps. However, all the operations to Azure SQL database need you to implement by yourself depend on which develop language you are using. You can refer to https://azure.microsoft.com/en-us/documentation/articles/sql-database-get-started/ for more details.

how widget is created only through script

I have come across few chat application and the website which I don't know how these things work. can someone tell me how these application works in the website.
I have seen some website with a chat widget for helping the customer for respective to their business. On signing in these application, a script file is send to email, when it is pasted over the website. Automatically a widget is created. And this widget and the application is connected externally.
Sorry, if my question is not clear. I will give some links of application and website which give you some idea what I'm trying to ask.
Website
http://www.a1000yoga.com/
http://www.voyzek.com/contact-us/
Application
https://www.zopim.com/
https://my.livechatinc.com/
What you mean is called providing Web API,
Wikipedia's definition of Web API is :
A server-side web API is a programmatic interface consisting of one or
more publicly exposed endpoints to a defined request-response message
system, typically expressed in JSON or XML, which is exposed via the
web—most commonly by means of an HTTP-based web server. Mashups are
web applications which combine the use of multiple server-side web
APIs.
In brief, They implement their service in their servers, and let you access their services by HTTP requests.
You sign up in their website and they generate a API token(a random string maybe), then when you want use their services, you send them your requests with your API token as authentication or identifying mean, and they process your request throw their application and with your data on their servers, and send you respond.
For example when you use this messaging services(or Captchas, Ads networks, etc), they provide a piece of Javascript containing your API code, then when someone views your web page, the code will send request with your API token to API provider servers and they process data for you.
You can then access to your data through their website, another API, email or etc.

executing webapi functions on client machine(Access db of the client system)

i've created a project(asp.net) - website
The database resides on the client machine.
Flow:
Client opens the website, and submit with the required fields, and then the server would authenticate.
Next, the api what i've created should be transferred to the Client pc, as the database would be accessible only where the client and server at the same system only.
Limitation: cannot move the database to the server, ie making database on the server.
If i'm hosting website on the localhost, everything is running fine, and also m fetching data from the database and i can see it on the browser.
But the same if i'm hosting website on server, m not able to fetch any result.
Is there any method or so, to execute on the client system that would be making connection between the cient browser and database residing on the client system only.
The whole scenario is same as of: bloomberg (what i came to knw about my issue and the bloomberg as a public db to be used issue), where bbg restricts its usage on the web, and bbg is accessble only for the client system for the client n on that client account only.
ON STRAIGHT: is it possible to access the client machine database or an application by browser.
Because i after making opening the website and also making some input and then submit, the call should call api which will access the data to be shown on browser would be from the client pc.(lets say - database resides at client pc)
No, there is no way to access a traditional database on a PC directly from the browser. You'd need a web app in the middle, so that your browser accesses the web app, and this offers indirect access to the database.
If you can install a web app that has access to the PC database, there are interesting ASP.NET and browser technologies to access the data: Web API OData + breeeze.js.
The only alternative would be to use HTML5 Storage databases, but they are still under definition and mostly unsupported. See, for example, this page: HTML5 Features: Storage. An this is not what you're looking for.

Facebook API: How to authenticate a web app

I am attempting to write a plugin for a webapp that integrates it with facebook using the Javascript API. The application is installed by our customers on their own servers each with their own site names. This poses a problem to me as Facebook wants me to specify a site url for the application. This url is going to be different for every customer. Creating a new application for each customer is not an option.
In my research of this problem it seems that I have to pretend to be a desktop app and follow that authentication path. I cannot figure out how to do this.
Anyone have any idea how this can be done?
Are you going to host the app as a canvas app or outside facebook?
Is the url important to you? There is a strict one-to-one relation between base-url and application.
What many apps do is host the apps as directories in their domain. For example http://crazy-fb-app.com/customername
That's your options basically if you want to use Javascript SDK.
If you're going to be using server side technology you could have the user authorize the application while requesting permission to access user's data while he's offline. in that case you will receive a non-expiring (or long-expiring) authentication token which you can use from the server to make Graph API calls on behalf of the user. For some stuff you can obtain an Application Auth token (which is shorter and non-user-specific) to make calls to the graph.
Rotem

Categories