Registered and received Chromecast AppId from Google.
Implemented simplest possible sender using Chrome API.
Sender works if I use YouTube for AppId but not if I use the AppId Google sent me.
Updated sender to listen for both at the same time. My Chromecast shows up in the YouTube list but not in the my AppId list.
I believe my sender is correct but my Chromecast was not correctly whitelisted. What do I do now?
JavaScript in my sender.html. My AppID obfuscated.
var myID = 'df7cb8ba-a00b-476b-a9b5-xxxxxxxxxxxx';
var ytID = 'YouTube';
onYtReceiverList = function(list) {
$(".ytreceivers").html("<p>YouTube Receiver List</p>");
for (var i = 0; i < list.length; i++) {
$(".ytreceivers").append("<p>"+list[i].id+"<br/>"+list[i].name+"</p>");
}
};
onMyReceiverList = function(list) {
$(".myreceivers").html("<p>My Receiver List</p>");
for (var i = 0; i < list.length; i++) {
$(".myreceivers").append("<p>"+list[i].id+"<br/>"+list[i].name+"</p>");
}
};
window.addEventListener("message", function(event) {
if (event.source == window && event.data &&
event.data.source == "CastApi" &&
event.data.event == "Hello")
{
$("body").append("<p>Hello received</p>");
cast_api = new cast.Api();
cast_api.addReceiverListener(myID, onMyReceiverList);
cast_api.addReceiverListener(ytID, onYtReceiverList);
}
});
One of the problems I had when starting with Chromecast development is that I forgot to make this setting: "Send this Chromecast's serial number when checking for updates." as mentioned at https://developers.google.com/cast/whitelisting#whitelist-receiver
I also had to reboot the Chromecast for the setting to take effect, but afterwards my Receiver showed up correctly.
Related
I am creating a slack bot and am trying to get the list of members in a slack workspace. Below is my code.
getUserList() {
axios.get(`https://slack.com/api/users.list?token=`+process.env.SLACK_BOT_TOKEN).then((res) => {
var jsonParsed = JSON.parse(res);
for (i = 0; i < jsonParsed; i++) {
workspace_users.push(jsonParsed[i].name);
}
});
},
I am getting below response.
{"ok":true,"no_op":true,"already_open":true,"channel":{"id":"*****"},"scopes":["identify","bot:basic"],"acceptedScopes":["im:write","post"]}
I went to https://api.slack.com/methods/users.list and I am not getting the kind of result mention in the URL.
I have already given the scope permission to my bot.
Any help would be appreciated.
Trying to create a facebook chatbot with NodeJS.
The problem is that I can easily handle user response to "button" messages with few choices to pick but can't handle input from simple text messages ("what is your favourite color?").
The conversation should be as follows :
Bot : Welcome, I have some questions for you.
What is your phone number?
User :
Bot : How old are you?
User :
etc.
So what would be the way out to make this flow of question->answer possible?
My code so far:
let messaging_events = req.body.entry[0].messaging;
for (let i = 0; i < messaging_events.length; i++) {
let event = messaging_events[i];
if (event.message && event.message.text) {
let text = event.message.text;
let textid = event.message.mid;
}
}
You can use this module facebook-chat-api.
Or read it to learn how to create it.
And are you using facebook-graph-api or login with NodeJs ?
I'm trying to implement google login in my app using xamarin.auth like below
var auth = new OAuth2Authenticator("284202576320-7kgdhaa5sgvkoe03jmmcv0p8lfdma306.apps.googleusercontent.com","cAZW7uegD-h2-
tNMMf5q1UGQ","https://www.googleapis.com/auth/userinfo.email",new
Uri("https://accounts.google.com/o/oauth2/auth"),new
Uri("http://dev.myfav.restaurant/Account/LoginComplete"),new
Uri("https://accounts.google.com/o/oauth2/token"),null,true)
{
AllowCancel = true,
};
but Completed event not firing and its going to web page after login :(
I'm getting below error
i need to get back user to my app how can i achieve this ???? Can anyone help me on this please.
Thanks in advance
Hey follow these two examples one is using web view and one is using google sign in sdk for google auth.
https://timothelariviere.com/2017/09/01/authenticate-users-through-google-with-xamarin-auth/
and
https://developer.xamarin.com/samples/xamarin-forms/WebServices/OAuthNativeFlow/
So according to this issue reported by Mounika.Kola .I think u should refer that authenticator.Completed -= OnAuthCompleted is there in ur code. For reference just see these codes which i used for google authorization in Xamarin Forms.
void OnLoginClicked(object sender, EventArgs e)
{
string clientId = null;
string redirectUri = null;
switch (Device.RuntimePlatform)
{
case Device.iOS:
clientId = Constants.iOSClientId;
redirectUri = Constants.iOSRedirectUrl;
break;
case Device.Android:
clientId = Constants.AndroidClientId;
redirectUri = Constants.AndroidRedirectUrl;
break;
}
var authenticator = new OAuth2Authenticator(
clientId,
null,
Constants.Scope,
new Uri(Constants.AuthorizeUrl),
new Uri(redirectUri),
new Uri(Constants.AccessTokenUrl),
null,
true);
authenticator.Completed += OnAuthCompleted;
authenticator.Error += OnAuthError;
AuthenticationState.Authenticator = authenticator;
var presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter();
presenter.Login(authenticator);
}
async void OnAuthCompleted(object sender, AuthenticatorCompletedEventArgs e)
{
var authenticator = sender as OAuth2Authenticator;
if (authenticator != null)
{
authenticator.Completed -= OnAuthCompleted;
authenticator.Error -= OnAuthError;
}
User user = null;
if (e.IsAuthenticated)
{
// If the user is authenticated, request their basic user data from Google
// UserInfoUrl = https://www.googleapis.com/oauth2/v2/userinfo
var request = new OAuth2Request("GET", new Uri(Constants.UserInfoUrl), null, e.Account);
var response = await request.GetResponseAsync();
if (response != null)
{
// Deserialize the data and store it in the account store
// The users email address will be used to identify data in SimpleDB
string userJson = await response.GetResponseTextAsync();
user = JsonConvert.DeserializeObject<User>(userJson);
}
if (account != null)
{
store.Delete(account, Constants.AppName);
}
await store.SaveAsync(account = e.Account, Constants.AppName);
await DisplayAlert("Email address", user.Email, "OK");
}
}
I hope it helps you.
In iOS once you have completed the authentication with Xamarin.Auth you just need to dismiss the viewController and you will be put back in your app.
You do this subscribing to the Completed event of the OAuth2Authenticator
auth.Completed += (sender, e) =>
{
DismissViewController(true, null);
};
If the "Native UI" is used (the last parameter in the constructor is set to true), which means that external/system browser is used for login not WebView. So, on Android instead of WebView [Chrome] CustomTabs is used and on iOS instead of UIWebView (or WKWebView) SFSafariViewController is used.
With native UI user is leaving your app and the only way to return to your app is app-linking (or deep-linking) and this requires completely different approach.
1st you cannot use http[s] scheme for redirect_url (OK on Android it is possible, but on iOS not). Use custom scheme for that.
See the sample[s] (Xamarin.Forms ComicBook):
https://github.com/moljac/Xamarin.Auth.Samples.NugetReferences
And the docs in the repo:
https://github.com/xamarin/Xamarin.Auth/tree/master/docs
I'm trying to implement an inapp purchase for my Chrome Extension. I have followed the guide on https://developer.chrome.com/webstore/payments-iap, added 1 buyable item and implemented following code on an onclick event:
google.payments.inapp.getSkuDetails({
'parameters': {'env': 'prod'},
'success': onSkuDetails,
'failure': onSkuDetailsFail
});
var onSkuDetails = function (response) {
console.log("onSkuDetails", response);
/*var products = response.response.details.inAppProducts;
var count = products.length;
for (var i = 0; i < count; i++) {
var product = products[i];
addProductToUI(product);
}
getLicenses();*/
}
var onSkuDetailsFail = function(result){
console.log("onSkuDetailsFailed", result);
}
But every time I click it, I get
onSkuDetailsFailed > "INVALID_RESPONSE_ERROR"
I have added the buy.js and changed some permissions, but still don't see where the problem might be.
Do note, that I'm testing this extension locally and not from the Chrome webstore using my own account and a friend's account which I included as testperson on the dashboard.
What is the best way to record statistics on the number of visitors visiting my site that have set their browser to block ads?
Since programs like AdBlock actually never request the advert, you would have to look the server logs to see if the same user accessed a webpage but didn't access an advert. This is assuming the advert is on the same server.
If your adverts are on a separate server, then I would suggest it's impossible to do so.
The best way to stop users from blocking adverts, is to have inline text adverts which are generated by the server and dished up inside your html.
Add the user id to the request for the ad:
<img src="./ads/viagra.jpg?{user.id}"/>
that way you can check what ads are seen by which users.
You need to think about the different ways that ads are blocked. The first thing to look at is whether they are running noscript, so you could add a script that would check for that.
The next thing is to see if they are blocking flash, a small movie should do that.
If you look at the adblock site, there is some indication of how it does blocking:
How does element hiding work?
If you look further down that page, you will see that conventional chrome probing will not work, so you need to try and parse the altered DOM.
AdBlock forum says this is used to detect AdBlock. After some tweaking you could use this to gather some statistics.
setTimeout("detect_abp()", 10000);
var isFF = (navigator.userAgent.indexOf("Firefox") > -1) ? true : false,
hasABP = false;
function detect_abp() {
if(isFF) {
if(Components.interfaces.nsIAdblockPlus != undefined) {
hasABP = true;
} else {
var AbpImage = document.createElement("img");
AbpImage.id = "abp_detector";
AbpImage.src = "/textlink-ads.jpg";
AbpImage.style.width = "0";
AbpImage.style.height = "0";
AbpImage.style.top = "-1000px";
AbpImage.style.left = "-1000px";
document.body.appendChild(AbpImage);
hasABP = (document.getElementById("abp_detector").style.display == "none");
var e = document.getElementsByTagName("iframe");
for (var i = 0; i < e.length; i++) {
if(e[i].clientHeight == 0) {
hasABP = true;
}
}
if(hasABP == true) {
history.go(1);
location = "http://www.tweaktown.com/supportus.html";
window.location(location);
}
}
}
}
I suppose you could compare the ad prints with the page views on your website (which you can get from your analytics software).