3
What are the odds of Googlebot read that code Rich Snippets?
Tips on how to improve are welcome...
I can only use Front-END, if you hadn’t already used one PHP to solve this.
<script type="text/javascript" src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script type="text/javascript">
var url_api_yql = 'https://query.yahooapis.com/v1/public/yql';
var url_json_tc = 'https://trustedcompany.com/api/v1/company/*?key=f157aee72a787417c20a71ac21708ee8-1b06b0bab68ccc183f78742e3bb8f852';
$.ajax({
'url': url_api_yql,
'data': {
'q': 'SELECT * FROM json WHERE url="' + url_json_tc + '"',
'format': 'json',
'jsonCompat': 'new',
},
'dataType': 'jsonp',
'success': function(response) {
document.getElementById("rating").setAttribute("content", response.query.results.content.rating);
document.getElementById("review_count").setAttribute("content", response.query.results.content.review_count);
}
});
</script>
<div vocab="http://schema.org/" typeof="Blog">
<div property="aggregateRating" typeof="AggregateRating">
<span id="rating" property="ratingValue"></span>
<span id="review_count" property="ratingCount"></span>
<meta property="bestRating" content="5" />
<meta property="worstRating" content="1" />
</div>
</div>
42.42% chance ;P
– Maniero
It’s just a joke ;)
– Maniero