Created
August 27, 2010 14:27
-
-
Save fourplusone/553448 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
# Copyright 2010 by Ben Collins <[email protected]> | |
# Licensed under the GPLv3 | |
# | |
# July 29, 2010: Flattr v0.2 load.js does not expect bin2hex for data | |
# anymore. Pass arguments as normal GET | |
include_once("simplehtmldom.php"); | |
function errout($msg) { | |
// echo $msg; | |
} | |
function uriencode($data) { | |
$ret = str_replace(array('\r\n', '\r', '\n'), '', $data); | |
$ret = urlencode($ret); | |
return $ret; | |
} | |
if (!isset($_GET['link'])) | |
errout("Need link passed"); | |
$uid = "895"; | |
$link = $_GET['link']; | |
$btn_url = "http://api.flattr.com/button/view/?"; | |
$data = "uid=$uid&url=$link&lng=$lng"; | |
# Now retrieve the button and extract some info from it | |
$btn = file_get_html($btn_url . $data); | |
if ($btn == '') | |
errout("Failed to get button code: $btn_url" . $data); | |
$els = $btn->find("span.flattr-count"); | |
$count = $els[0]->innertext; | |
if ($count == "!") | |
errout("Error from flattr.com"); | |
$els = $btn->find("a.flattr-pop"); | |
$link = $els[0]->href; | |
$els = $btn->find("span.flattr-link"); | |
$txt = $els[0]->innertext; | |
if ($link == '' or $txt == '') | |
errout("Invalid information from flattr.com"); | |
if($_GET['callback'] != null) | |
{ | |
echo 'window[' . json_encode($_GET['callback']). '](' .$count . ');'; | |
}else | |
{ | |
echo $count; | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.get('http://example.com/fltr.php?link=http://wirres.net/article/articleview/5634/1/6/', function(data) { | |
$('#element').html(data) | |
}, 'jsonp'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment