I was trying to put the following code to my website in order to get the number of Linkedin followers(Taken from the linkedin itself). However, it works perfectly on their website "preview" section.
CODE:
<script src="//platform.linkedin.com/in.js" type="text/javascript">
lang: en_US
</script>
<script type="IN/FollowCompany" data-id="9223418" data-counter="right"></script>
You need to specify the protocol for the source (in this case, http):
<script src="http://platform.linkedin.com/in.js" type="text/javascript">
lang: en_US
</script>
<script type="IN/FollowCompany" data-id="9223418" data-counter="right"></script>
I am surprised The LinkedIN official SDK getting started page still has this error so I can see why you do it without the protocol...
Per others, you need to add the protocol but it should be "https" as opposed to "http".
Also, I believe you would need to specific you API key (a.k.a. Client ID). According to the documentation:
<script type="text/javascript" src="//platform.linkedin.com/in.js">
api_key: [API_KEY]
onLoad: [ONLOAD]
authorize: [AUTHORIZE]
lang: [LANG_LOCALE]
</script>
Related
I have the problem with Telegram Web App and Google App Script.
I can browser the web (that build on google app script) on Telegram bot but can not receive value from initDataUnsafe from Telegram Bot return (I use Menu Button on Bot to browser the web app)
I have try to build the web app on Flask and my server, the web app bot working and return initDataUnsafe correctly.
Maybe Google App Scipt is not working with Telegram Web Bot, anyone have the same problem with me, and let me know the root cause. Thank you so much!
I flowing this document: https://prog.world/creation-of-telegram-web-apps-and.../
Here is my code:
<html>
<head>
<base target="_top">
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<script src="https://telegram.org/js/telegram-web-app.js"></script>
<body>
<h1 id="console">Hello1</h1>
<button id="check_btn" type="button" class="btn btn-primary">Check</button>
</body>
<script>
var tg = window.Telegram.WebApp;
tg.expand();
document.getElementById("check_btn").addEventListener("click", doStuff);
function doStuff() {
console.log("Button is clicked!");
document.getElementById("console").innerHTML = tg.initDataUnsafe.user;
}
</script>
</html>```
There seems to be a bug with the LinkedIn JS SDK. You're able to reproduce with the code they supply in the "Getting Started" section of the docs.
<!DOCTYPE html>
<html>
<head>
<title>LinkedIn test</title>
<script>
// Setup an event listener to make an API call once auth is complete
function onLinkedInLoad() {
IN.Event.on(IN, "auth", getProfileData);
}
// Handle the successful return from the API call
function onSuccess(data) {
console.log(data);
}
// Handle an error response from the API call
function onError(error) {
console.log(error);
}
// Use the API call wrapper to request the member's basic profile data
function getProfileData() {
IN.API.Raw("/people/~").result(onSuccess).error(onError);
}
</script>
<script type="text/javascript" src="//platform.linkedin.com/in.js">
api_key: [API_KEY]
onLoad: onLinkedInLoad
</script>
</head>
<body>
<script type="in/Login"></script>
</body>
</html>
If you put this code on a non-https site and hit that URL on iOS Safari, clicking the "sign in with LinkedIn" button will initiate authorization, but the 'auth' callback will never fire. Instead, you'll get a CORS error in the console:
"Uncaught SecurityError: Blocked a frame with origin "https://platform.linkedin.com" from accessing a frame with origin ..."
All other environments seem to work fine (e.g. Chrome, FF, IE, Desktop Safari, Android browsers, etc.). I'm also able to reproduce the issue if I set the user agent to an iOS device in Chrome's dev tools, which makes me think the JS SDK is doing user-agent sniffing.
Is there a workaround? Is the LinkedIn dev team aware of this issue? Did I miss a Monday detail?
PS This is probably related: Sign in with Linkedin doesn't trigger callback on iOS Safari when using the JS API
According to LinkedIn's Getting Started with the JavaScript SDK page, the LinkedIn JavaScript SDK doesn't support iOS 5+.
Note: The JavaScript SDK is not compatible with iOS 5+.
#degrassesagan I think you need to do the following:
function onLinkedInLoad() {
IN.Event.on(IN,"auth",getProfileData);
IN.Event.on(IN,"success",onSuccess);
IN.Event.on(IN,"error",onError);
}
There is also a side issue, I have discovered, in relation to the LinkedIn JS SDK. I am using mobile Safari 10.3.3, and although the login business logic executes correctly, the URL flow does not.
After a successful login, the page goes to a LinkedIn 'Page Not Found' page, rather than closing the current browser tab, to reveal the owner's page underneath?
I am not sure whether this is connected to the original question or not, but I would be grateful, if anyone could shine a light on this problem.
I'm attempting to implement the GITKit in a Asp .NET Web Api 2 application.
I followed the instructions on the google developer kit. When I go to my sign in page, it redirects to accountchooser.com. So far, so good. I have a google account shown, so I select it. The page reloads, but it is completely blank. No call is received on my sign in successful url. The javascript console shows:
Uncaught Error: At least one sign in option should be specified! gitkit.js:250
Any ideas? What am I doing wrong? How does one debug the various calls to see where things are going haywire?
Thanks.
in your sign in html page where window.google.identitytoolkit.start() is called, you need to pass a configuration object to the start() method with signInOptions defined. Below is an example:
<script type="text/javascript" src="//www.gstatic.com/authtoolkit/js/gitkit.js"></script>
<link type="text/css" rel="stylesheet" href="//www.gstatic.com/authtoolkit/css/gitkit.css" />
<script type="text/javascript">
var config = {
apiKey: '...',
signInSuccessUrl: '/',
signInOptions: ["google", "password"]
};
window.google.identitytoolkit.start(
'#gitkitWidgetDiv', // accepts any CSS selector
config);
</script>
No matter how hard I try, and no matter the url format I'm giving in the Setting the SDK Domains section of the Linkedin Javascript SDK, I keep getting this error in my console:
Uncaught Error: You must specify a valid JavaScript API Domain as part of this key's configuration.
My setup it's as simple as possible :
<script type="text/javascript" src="//platform.linkedin.com/in.js">
api_key:afyXZGKtvrVoXXXX
</script>
I've tried all the URL variations in the SDK Domains section:
having localhost with and without port ( http://localhost:9000 )
having a custom hostname with and without port ( http://dev.local:9000 )
having a real existing domain name ( heroku app ) (http://somename.herokuapp.com)
Nothing worked, keep getting the same error.
Any advice appreciated.
Thank you,
Try this:
<script type="text/javascript" src="//platform.linkedin.com/in.js">
api_key:afyXZGKtvrVoXXXX
authorize: true
</script>
When using Google Analytics and using the newer ga.js file, is the __utm.gif file needed in your root directory of your web site?
I do see a call being made from my browswer to the file on google-analytics.com (http://www.google-analytics.com/__utm.gif?...), but in the past I was told that it needed to exist in the root of the site.
Does this still hold true?
Could you please provide a reference?
If you are using the new version of the tracking code (ga.js), the only thing you need to do is include this snippet of JavaScript:
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-xxxxxx-x");
pageTracker._trackPageview();
</script>
This would imply that there are no requirements for you to host any __utm.gif file on your server (I'm not sure how this would even work for analytics anyway, as the whole point is for the client's browsers to make requests to Google's servers).
I use the older urchin.js tracking mechansim and there are no requirements to host anything locally although you can put the .js file on your server for speed. There are four images that get requested to provide the tracking; __utma, __utmb, __utmc and __utmz which correspond to they cookies recorded of the same name.
From Google; When you first begin implementing tracking in Google Analytics website, you need to install the tracking code on your website pages. The generic tracking code snippet consists of two parts: a script tag that references the ga.js tracking code, and another script that executes the tracking code.
You are required to add _utm.gif to your server root if you are also sending a copy of the google analytics data to your local webserver. It gives you the option of keep the data much longer since Google is only keeping 25 months of data for free account.
Google also doesn't share the raw data, the only way to get the raw data is also sending it to your local webserver log. For it to work, you need to add this line below to the tracking code:
_gaq.push(['_setLocalRemoteServerMode']);
For more detailed discussion, please refer to the book by Clifton, Brian (2012-03-30). Advanced Web Metrics with Google Analytics (Kindle Locations 4459-4460). John Wiley and Sons.