How does one query the "parameters" sent to a Chromecast Reciever app? - google-cast

The docs shown on this page demonstrate how to send arbitrary parameters from a sender app to a receiver app:
https://developers.google.com/cast/chrome_sender
Specifically, here:
request.parameters = "v=abcdefg";
But, I don't see how the receiver app is supposed to access those parameters once sent? Does someone have an example of jscript for a receiver to see this string?

It looks like Chromecast pulls down the built-in application settings from the following URL: https://clients3.google.com/cast/chromecast/device/config
If you take a look at that file, you'll notice that many of the URLs look like this:
https://www.youtube.com/tv?${POST_DATA}
Notice that ${POST_DATA} is specified as part of the URL that defines the application. I am only guessing, but I would assume that unless your application is setup similarly on Google's whitelist, that you'll be unable to receive that data via the URL.
It may be worth using a channel to send the data you require to your application instead of trying to use request.parameters.

This should be passed in the query parameter section of the URL that the receiver loads. For example, if your app URL is:
http://example.com/foo.html
and you set:
request.parameters = "bar=baz";
then the full URL should come out as:
http://example.com/foo.html?bar=baz
From your receiver JavaScript, you can interrogate this value with document.location.search.

Related

Serving a HTTP request response as a dialog response - Composer Framework

We are developing a chatbot to handle internal and external processes for a local authority. We are trying to display contact information for a particular service from our api endpoint. The HTTP request is successful and delivers, in part, exactly what we want but there's still some unnecessary noise we can't exclude.
We specifically just want the text out of the response ("Response").
Logically, it was thought all we need to do is drill down into ${dialog.api_response.content.Response} but that fails the HTTP request and ${x.content} returns successful but includes Tags, response and the fields within 1.
Is there something simple we've missed using composer to access what we're after or do we need to change the way our endpoint is responding 2? Unfortunately the MS documentation for FrwrkComp is lacking to say the very least.
n.b. The response is currently set up as a (syntactically) SSML response, this is just a test case using an existing resource.
Response in the Emulator
Snippet from FwrkComp
Turns out it was the first thing I tried just syntactically correct. For the case of the code given it was as simple as:
${dialog.api_response.content[0].Response}

Using Azure functions output in an HTML file

I use my Azure function to return a certain output after passing an HTML trigger. The webpage prints out basic output, like Hello {name}.
I would like to pass this output into an HTML file and display it via a separate HTML file. Essentially, I want to extract what my helloworld.azureapp.com?name={name} returns and push it into a JS variable in an HTML file.
How would I do this?
Note that the Azure function is written in Python.
If I understand correctly, what you're looking for is to make your web application send a GET request to your azure function endpoint and store the response you get back in a javascript variable.
You should treat the responses from an Azure function HTTP trigger just like any standard response from any API.
Instead of writing all js code in native HTML files, it is recommended you pick a simple web application framework.
For python, you can try Django or Flask (introductory tutorials here).
The code that calls your Azure function endpoint helloworld.azureapp.com?name={name}
could be in your web application (using the requests module in python). Tutorial on how to make web requests in python here.
Once you get back the response for that request, you can do further processing with the values you get back.
Depending on your web application framework, you could do many things.
Some of them are:
Save it in a hidden field and get value in JavaScript.
Render the received values to element in page on server side and show it.

Azure Remote Monitoring - How to add parameters to CloudToDeviceMethods?

In Azure Remote Monitoring, you can create your own CloudToDeviceMethods. How do you add parameters to those methods?
Usually those methods look like this:
function main(context, previousState, previousProperties) { ... }
...in a .js file that has the name of a specific method. But I don't see how I can add parameters to a method like that. I also want to see those parameters in the Azure Remote Monitoring Solution Accelerator web, so I can call that method and send in some parameters.
A CloudToDeviceMethod supports exactly one parameter, and that is the JSON payload that you can give to it. Of course you can add many properties to that payload to act like separate parameters. On the device side, reading that parameter looks like this in C# and like this in JavaScript (Node example)
You mentioned that you want to be able to add those parameters in the Remote Monitoring Solution Accelerator. This is entirely possible with some changes to the ReactJS code. The main files you need to look at are the Job page, right now it calls the device method without a body. Eventually the request is built here, you can see the JsonPayload is left empty.

Routing in WCF data services

I am creating a WCF data service on top of a EF 4.1 code first data model that goes against a multi-tenant database. In order to enforce the rules of accessing the multi-tenancy I want to require a string id (that is required by all of our MVC-based REST services) be passed as part of the url route. So, for example, right now I have a service route like this:
http://mysample.net/mysamplesvc.svc/Users
That returns all users in the db w/o a filter. I want to partition this by client by requiring the client id be passed as part of the request like this:
http://mysample.net/mysamplesvc.svc/client123/Users
If it is not passed-in or is invalid I will handle it as required. However, I do not see any example like this anywhere. I think I must be searching incorrectly as this seems like a pretty common scenario.
TIA!
The sample service at http://services.odata.org/(S(readwrite))/OData/OData.svc/ does this (it creates a new instance of the data for each (S(...)) in the URL).
The service code is the last sample on this page: http://www.odata.org/ecosystem#samplecode

Can I capture JSON data already being sent with a userscript/Chrome extension?

I'm trying to write a userscript/Chrome extension to capture JSON data being sent while using a web service so that I can reformat it and display selected portion on page. Currently the JSON is sent as the application loads (as I've observed from watching traffic with Fiddler 2). Is my only option to request the JSON again or is capture possible? As I'm not providing a code example, a requested answer is even some guidance on what method / topic to research or if I'm barking up the wrong tree.
No easy way.
If it is for a specific site you might look into intercepting and overwriting part of a code which sends a request. For example if it is sent on a button click you can replace existing click handler with your own implementation.
You can also try to make a proxy for XMLHttpRequest. Not sure if this even possible, never seen a working example. You can look at some attempts here.
For all these tasks you probably would need to run your javascript code out of sandboxed content script to be able to access parent page variables, so you would need to inject <script> tag with your code right into the page from a content script:

Resources