Skip to content

Commit

Permalink
Merge pull request Julienh#81 from LimeBlast/patch-1
Browse files Browse the repository at this point in the history
Fixed issued with sharrre.php
  • Loading branch information
Julienh committed Sep 20, 2012
2 parents 4962084 + 381d003 commit 775fe2f
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions sharrre.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
header('content-type: application/json');
//Sharrre by Julien Hany
$json = array('url'=>'','count'=>0);
$json['url'] = $_GET['url'];
Expand All @@ -17,21 +18,29 @@
$newDom->formatOutput = true;

$filtered = $domxpath->query("//div[@id='aggregateCount']");
$json['count'] = str_replace('>', '', $filtered->item(0)->nodeValue);
if (isset($filtered->item(0)->nodeValue))
{
$json['count'] = str_replace('>', '', $filtered->item(0)->nodeValue);
}
}
else if($type == 'stumbleupon'){
$content = parse("http://www.stumbleupon.com/services/1.01/badge.getinfo?url=$url");

$result = json_decode($content);
$json['count'] = $result->result->views;
if( !isset($json['count']) ) $json['count'] = 0;
if (isset($result->result->views))
{
$json['count'] = $result->result->views;
}

}
else if($type == 'pinterest'){
$content = parse("http://api.pinterest.com/v1/urls/count.json?callback=&url=$url");

$result = json_decode(str_replace(array('(', ')'), array('', ''), $content));
$json['count'] = $result->count;
if( !isset($json['count']) || $json['count'] === '-' ) $json['count'] = 0;
if (is_int($result->count))
{
$json['count'] = $result->count;
}
}
}
echo str_replace('\\/','/',json_encode($json));
Expand Down Expand Up @@ -67,4 +76,3 @@ function parse($encUrl){
}
return $content;
}
?>

0 comments on commit 775fe2f

Please sign in to comment.