I'm adding a LinkedIn share button to my site. The URL that needs to be shared includes a parameter, but LinkedIn is stripping the parameter from the URL. Any way to get around this?
I've tried using a custom share URL e.g.
http://www.linkedin.com/shareArticle?mini=true&url=https://stackoverflow.com/questions/10713542/how-to-make-custom-linkedin-share-button/10737122&title=How%20to%20make%20custom%20linkedin%20share%20button&summary=some%20summary%20if%20you%20want&source=stackoverflow.com
I've also tried using their share plugin e.g.
<script src="https://platform.linkedin.com/in.js" type="text/javascript">lang: en_US</script>
<script type="IN/Share" data-url="https://website.com/?par=1"></script>
Neither option is working for me. The URL just defaults to the root domain.
LinkedIn no longer supports those parameters.
2010:
https://www.linkedin.com/cws/share?url={url}
2016:
https://www.linkedin.com/shareArticle?url={url}&title={title}&summary={text}&source={provider}
2020:
https://www.linkedin.com/sharing/share-offsite/?url={url}
Unfortunately, we will have to survive with only a url parameter.
Source: Official Microsoft LinkedIn Share API Docs.
But, if you want to show a preview of some site info on the share page, before the user clicks to share it, you can use og: tags...
<meta property='og:title' content='Title of the article"/>
<meta property='og:image' content='//media.example.com/ 1234567.jpg"/>
<meta property='og:description' content='Description that will show in the preview"/>
<meta property='og:url' content='//www.example.com/URL of the article" />
Source: LinkedIn Developer Docs: Making Your Website Shareable on LinkedIn.
And when you're all done: Test it with the LinkedIn Post Inspector.
Related
I am trying to scraping data from a site provide note of student to make analysis
I try this good
from selenium import webdriver
#set chromodriver.exe path
driver = webdriver.Chrome(executable_path="C:\\chromedriver.exe")
#set page load timeout
#launch URL
driver.get("https://amatti.education.gov.dz/")
the first thing happen when run this code is open the site :
[the site open normal][1]
https://i.stack.imgur.com/ay7QJ.png
after the site open it go to this site :
[after open go to this site][2]
https://i.stack.imgur.com/NWvEa.png
I notice there is this good in the html of the site
that mean if the browser not support JavaScript will go to URL : google.com
<noscript>
<meta http-equiv="refresh" content="0; url=http://www.google.com/" />
</noscript>
there is any solution to automate this site
[1]: https://i.stack.imgur.com/ay7QJ.png
[2]: https://i.stack.imgur.com/NWvEa.png
I found the solution
the problem comes from WebDrive
the site knows there is bot scraping data
so i use this argument
options.add_argument("--disable-blink-features=AutomationControlled")
and its work fine
I have written an interface to use with an Alexa Smart Thermostat skill. I am using Google Oauth for credential checking and I followed the guide here: https://nicogaspa.medium.com/alexa-skill-account-linking-with-google-apis-2cbad07d2cf8 which has also been discussed here: Alexa skill account linking with Google APIs credentials, problem refreshing token
This has worked well for me until recently when I found that the skill had stopped working and I was unable to re-enable it. There are two problems that I am aware of:
The Google API appears to have changed and the Authorization URI now requires a number of mandatory parameters – client_id, redirect_uri, response_type & scope. I have added all of these to the URI specified on the Account Linking page in the Alexa developer console and the account linking now works OK (including the automatic refreshing of the token).
Having added the mandatory parameters, I have tried to get this to work on the HTML page that I used from Nicolo’s blog. I have been unable to get this to work, because Google complains with: “OAuth 2 parameters can only have a single value: client_id” (the reference to client_id is a red-herring as it changes depending on what’s included in the string). From searching around, it would appear that this is caused by having the parameters in the body and the header of the request. However, I can’t find a way to prevent this from happening. My HTML page looks like this:
<html lang="en-us">
<head>
<title>Your Skill</title>
</head>
<body>
<div>
<p>Welcome to the skill</p>
<p>Click on the button to continue</p>
</div>
<script language="javascript" type="text/javascript">
var urlParameter = window.location.search.substr(1);
</script>
<a href="https://accounts.google.com/o/oauth2/v2/auth?access_type=offline&response_type=code&client_id=MYID.apps.googleusercontent.com&redirect_uri=https://layla.amazon.com/api/skill/link/MYURI&scope=https://www.googleapis.com/auth/userinfo.email"
onclick="location.href=this.href+urlParameter;return false;">
Login
</a>
</body>
</html>
Any ideas on how to call the api from the body of a webpage without including the parameters in the header and the body?
Thanks.
We're running a service on our-site.com. Our customers can either use the service "stand alone" by simply linking from their-site.com to our-site.com/customer-service or by embedding our service via iFrame into their-site.com. Imagine visiting GMaps directly vs. seeing it embedded in an IFrame.
Visiting "foreign" page with our service in IFarme
Beginning with Chrome 80 (i guess) our Google Analytics stopped working when the service runs inside the iFrame. Chrome is giving me this (quite clear) message:
A cookie associated with a cross-site resource at http://our-site.com/ was set without the SameSite attribute. It has been blocked, as Chrome now only delivers cookies with cross-site requests if they are set with SameSite=None and Secure. You can review cookies in developer tools under Application>Storage>Cookies and see more details at https://www.chromestatus.com/feature/5088147346030592 and https://www.chromestatus.com/feature/5633521622188032.
Also I don't see anything in the GA realtime overview if I visit their-site.com with our our-site.com/customer-service embedded in the iFrame.
If I manually disable the 2 features same-site-by-default-cookies & cookies-without-same-site-must-be-secure in chrome://flags and visit their-site.com with our-site.com/customer-service embedded in the iFrame I do see the page visit in the GA realtime overview.
Visiting our service "stand alone"
When directly visiting our-site.com/customer-service GA is still working just fine:
No warnings in dev tools
Multiple cookies associated to GA are shown in dev tools > applications tab
I can see page visits in the GA realtime overview
Neither of the cookies has the Secure or SameSite value set (all "blank")...
Question
Is there anything I can do to make GA work again when running inside an iFrame on a foreign domain?
Example code
I just created a very simple test environment which also shows the issues described above:
our-site.com/customer-service
<html lang="en">
<head>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id={tracking-id}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag("js", new Date());
gtag("config", "{tracking-id}");
</script>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>our site service</title>
</head>
<body>our-site.com/customer-service</body>
</html>
their-site.com
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>their-site.com</title>
</head>
<body>
<iframe src="https://www.our-site.com/customer-service" style="width: 500px; height: 500px;"></iframe>
</body>
</html>
Even this very simple example shows the behavior described above, where opening our-site.com/customer-service directly, shows data in the GA realtime overview and opening their-site.com doesn't...
Answer from the Google tag manager support forum:
When accessing a first-party cookie (_ga) in a third-party context (the iframe), one has to explicitly add cookieFlags with the value samesite=none;secure.
Detailed description for various scenarios can be found at this blogpost.
The scenario I'm going to describe is about Excel, but you can spot the same problem in all Office tools.
Scenario:
In my default browser (NOT Internet Explorer) I'm logged in my own specific website, let's call it www.mypersonalwebsite.com
I have an Excel folder with the A1 cell containing a URL pointing to http://www.mypersonalwebsite.com/url/visible/only/to/loggedin/users
When I click on the URL in A1 cell:
my default browser is trying to open this URL
the website is refusing to serve the page because the request is coming from a non logged in user
So that's the problem: why is the browser complaining about the user session when I'm already logged in? And how can I solve it?
I found many similar questions about this problem on stackoverflow and I think I composed a portable and "definitive" solution to this problem.
First of all: why is the browser complaining about the user session?
The answer is "Microsoft Office Protocol Discovery". In a few words: it's something that works only if you are using Microsoft Windows and your default browser is Internet Explorer.
Basically, if you are not using Microsoft Windows OR your default browser is not Internet Explorer, when you click on an URL, the request sent to the browser will always be with an empty cookie. This means that, despite the default browser could use a correct cookie to authenticate the user, the request coming from Excel will never use it. But if you try to reload the page (and the webserver is not redirecting to a different error page), the browser will use the domain cookie and you'll see the correct page.
Second question: how can I solve this problem?
I think I found a very good solution, composed by an HTML part and a webserver part.
HTML part
Starting from the fact that you need to reload the page to use the cookie, I created a simple static page containing a little javascript code and some html. This is just an example. The main part of this code is here.
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<script type='text/javascript'>
function getParameterByName(name) {
var match = RegExp('[?&]' + name + '=([^&]*)').exec(window.location.search);
return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
}
</script>
<meta charset="UTF-8">
<script type="text/javascript">
window.location.href = getParameterByName('newUrl');
</script>
<title>Page Redirection</title>
</head>
<body>
<!-- Note: don't tell people to `click` the link, just tell them that it is a link. -->
If you are not redirected automatically, follow the <a href='<?php echo $newUrl; ?>'>link</a>
</body>
</html>
You can access to the querystring via javascript in many ways, you can find a very interesting thread here.
This static page, let's call it redirect.html, will only do one thing: it will redirect the browser to the page specified in the newUrl parameter. Now if I put in the A1 cell something like:
http://www.mypersonalwebsite.com/redirect.html?newUrl=http://www.mypersonalwebsite.com/url/visible/only/to/loggedin/users
and if I click on this URL:
Excel will go to this URL using the default browser
The browser will open the redirect.html page with an empty cookie
The browser will reload the page using the domain cookie
The user will see the correct page as an authenticated user
The pros of this trick are: it works on all platforms and on all browsers supporting javascript. The cons are that we need to modify all URLs in all our Excel folders.
The webserver part
To hide this redirection to the end users, and save us to modify all our Office documents, we can use another trick. In this example I will use nginx:
if ($http_user_agent ~* "(Excel|PowerPoint|Microsoft Office)") {
rewrite ^/(.*)$ /redirect.html?url=$1 break;
}
The meaning of this little if block is: if the incoming request is from a user agent like Excel, Powerpoint and so on, nginx will do an internal redirection to the redirect.html page, that will again do the browser redirection explained above.
This nginx redirect will completely hide the redirect trick, so we can use the original URLs and the users will always see the correct page.
I'm sure all this can be improved, and I would like to learn how to do it.
I hope this will help someone in finding a complete solution to this Office problem.
I am writing a flex3 tool for our uber-geeks. The tool is for futzing around with sharing URLs to various various social sites.
private function submitRequest(evt:Event):void {
var requestURL:URLRequest = new URLRequest(constructURL());
requestURL.method=URLRequestMethod.POST;
var header:URLRequestHeader = new URLRequestHeader("og:title", "petertitle");
requestURL.requestHeaders.push(header);
navigateToURL(requestURL,"_blank");
}
I want allow the developer to manipulate the following meta headers in the outgoing html request when navigateToURL() is called.
<meta property="og:title" content=title" />
<meta property="og:description" content="description" />\
<meta property="og:image" content="......" />
<meta property="og:video" content="......"/>
<meta property="og:video:height" content="640" />
<meta property="og:video:width" content="480" />
Unfortunately google is not showing me any example of how to add the above meta headers to my instance of URLRequest in flex. AND the new URLRequestHeader is blowing up.
ArgumentError: Error #2096: The HTTP request header og:title cannot be set via ActionScript.
at global/flash.net::navigateToURL()
Can someone point me at an example of putting the meta headers into a URLRequest?
additional
Looks like I am in a catch 22 situation.
I wrote the app to run in a flash player.
apparently the flash apps run from flashbuilder are not permitted to perfom http PUT method operations. it alwasy does GET
flash apps run from flashbuilder will not write headers on http GET calls.
But I am still not finding a way to add an http "meta" header tag in flex... perhaps adobe air.
Current work around.
I can call an external javascript function that will do a post, but however the XmlHttpRequest infrastructure only want to setRequestHeader(key,value), and seems to need to be from a very specific list of strings. setRequestHeader("foo","bar") did not add a foo header in my outgoing request.
There does not seem to be a way to add the header meta tag. via javascript. Or at lease I am not finding it off of google.
Hoping someone can now point me at how to do that?????
Do either of these help (appears the first one is particularly relevant, otherwise in the second a work-around is offered):
How can i send custom headers with URLRequest
Custom headers possible with URLRequest/URLStream using method GET?
What a pain. I would have thought someone would have run into this before and posted such a solution
setRequestHeader(arg1, arg2) ouptputs "< arg1 arg2 />" in the outgoing http request
so if I
xmlhttp.setRequestHeader("meta","property=\"og:description\" content=\"description\"");
then the outing html
<head>
....
<meta property="og:description" content="description"/>
....
</head>
<body>
....
</body>