Skip to content

Instantly share code, notes, and snippets.

@gebi84
Last active August 29, 2015 14:09
Show Gist options
  • Save gebi84/7a6a162f5f0663d67c3f to your computer and use it in GitHub Desktop.
Save gebi84/7a6a162f5f0663d67c3f to your computer and use it in GitHub Desktop.
display all comments from a www.indiegogo.com campaign
<?php
$file = 'cache.txt';
$time = filemtime($file);
if(time() > $time+300) {
$cache = false;
$url = 'https://www.indiegogo.com/projects/the-dragonfly-futurefon--3/show_tab/comments?count=9999';
// Erzeugen eines Streams
$opts = array(
'http'=>array(
'method'=>"GET",
'header'=>"Accept-language: en\r\n" .
"X-Requested-With:XMLHttpRequest"
)
);
$context = stream_context_create($opts);
// Öffnen der Datei mit den oben definierten HTTP-Headern
$content = file_get_contents($url, false, $context);
$handle = fopen($file, 'w+');
fwrite($handle, $content);
fclose($handle);
} else {
$cache = true;
$content = file_get_contents($file);
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Comments</title>
<style>
.row {
border-bottom: 1px solid #dddddd;
}
.i-musty-background {
display:none;
]
</style>
</head>
<body>
Comments from <a href="https://www.indiegogo.com/projects/the-dragonfly-futurefon--3/x/9126533#home">https://www.indiegogo.com/projects/the-dragonfly-futurefon--3/x/9126533#home</a>
<br />Site is Cached for 5 minutes<br />
<br /><br />
<?php echo $content; ?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment