I made custom share buttons and wanna add Pocket count to them.
If you're open this link https://widgets.getpocket.com/v1/button?count=vertical&url=http://google.com in browser, you'll see Pocket button with counter (for ex. URL is google.com).
It's simple html document:
<html><head>
<link rel="stylesheet" type="text/css" href="https://d7x5nblzs94me.cloudfront.net/v1/c/button.css?v=6">
<script type="text/javascript" src="https://d7x5nblzs94me.cloudfront.net/v1/j/shared.js?v=2"></script>
<style type="text/css"></style></head>
<body>
<div class="widget vertical pocket center">
<a id="btn">
<!--
Please do not scrape this for the Pocket count.
It is not relible for you to use and will likely change.
Contact us at api@getpocket.com for an official API.
Thanks!
-->
<span><em id="cnt">126775</em><i></i><u></u></span>
<b></b>
</a>
</div>
<script type="text/javascript">
var POCKET_DOMAIN = 'getpocket.com';
var iLi = true;
var btnData = {"mode":"viapocketbutton","ct":"b607befed1e75f78567281514cae33db78cbcab9","ctn":"ed82217ee621d17ee56ca091cd836e96149b7921","label":"pocket","count":"vertical","src":"","url":"http:\/\/google.com"};
</script>
<script type="text/javascript" src="https://d7x5nblzs94me.cloudfront.net/v1/j/button.js?v=5"></script>
</body></html>
How to parse this Pocket count (placed on <em id="cnt">...</em>
) with jQuery.ajax()
or something else (js)?
Forgive me, Im on mobile. You should be able to make a GET request by using jQuery's ´load()´ function.
The function takes a url and callback that, once the request has processed, will return the html from the pocket:
$.load(myURL, function(data){
var dom = $(data).html()
var pocket = dom.find('pocket selector')
});
Once you have access to ´dom´, querying for the button and then using ´text()´ to grab it is probably the route Id go!