以编程方式获取 LinkedIn 共享页面统计信息
我正在寻找一种方法来获取页面的 linkedin 共享按钮统计信息。 例如,我正在编写一个 PHP 类,当您在网站上使用我的类时,如下所示:
include("shareButtonStats.class.php");
$stats = new shareButtonStats;
echo "This page shared " . $stats->show . " times on LinkedIn";
如您所见,我需要获取该页面的共享次数统计信息。
如您所知,当我们为共享按钮添加 L??nkedIn 的 js 文件时(从这里),它包括我们页面的一些 HTML 代码。像这样的事情:
<span class="IN-widget" style="line-height: 1; vertical-align: baseline; display: inline-block; text-align: center;">
<span style="padding: 0pt ! important; margin: 0pt ! important; text-indent: 0pt ! important; display: inline-block ! important; vertical-align: baseline ! important; font-size: 1px ! important;">
<span id="li_ui_li_gen_1321370527058_1-container" class="IN-top">
<span id="li_ui_li_gen_1321370527058_1" class="IN-top">
.......
如果我得到该 HTML 代码,而不将其直接包含到页面中,我可以在其上使用正则表达式,然后获取共享按钮计数:)
你对我有什么想法吗?
I'm looking for a way to getting linkedin share button stats of a page.
For example, I'm writing a PHP class, when you use my class on your website like this:
include("shareButtonStats.class.php");
$stats = new shareButtonStats;
echo "This page shared " . $stats->show . " times on LinkedIn";
As you can see I need to get that page's stats for how many times shared .
As you know when we add LİnkedIn's js file for Share Button (from here), it's including some HTML codes to our page. Something like this :
<span class="IN-widget" style="line-height: 1; vertical-align: baseline; display: inline-block; text-align: center;">
<span style="padding: 0pt ! important; margin: 0pt ! important; text-indent: 0pt ! important; display: inline-block ! important; vertical-align: baseline ! important; font-size: 1px ! important;">
<span id="li_ui_li_gen_1321370527058_1-container" class="IN-top">
<span id="li_ui_li_gen_1321370527058_1" class="IN-top">
.......
If I get that HTML codes, without including it to page directly, I can use a RegEx over it, and then get share button count :)
Have you got any idea for me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我相信他们会这样做,而且它是一个需要 URL 的简单网页。它返回 JavaScript 或 PHP 可以解析的 JSON
,希望这有帮助
http://www.linkedin.com/countserv/count/share?url=http://www.apple.com
I believe they do and its a simple web page that requires the URL. it returns JSON which either JavaScript or PHP could parse
hope this helps
http://www.linkedin.com/countserv/count/share?url=http://www.apple.com
LinkedIn 提供了一个外部 API 来完成此任务。以下是您可以如何使用它:
我使用了 cURL,但是您可以使用另一种下载页面的方法。
有关现场演示,请参阅:http://codepad.viper-7.com/VDD5aI
LinkedIn provides an external API that does just that. Here is how you might use it:
I used cURL for this, however you could use another method of downloading the page.
For a live demo, see: http://codepad.viper-7.com/VDD5aI