Skip to content

Instantly share code, notes, and snippets.

@lplume
Created January 24, 2011 16:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lplume/793487 to your computer and use it in GitHub Desktop.
Save lplume/793487 to your computer and use it in GitHub Desktop.
mini wrapper web based, look for questions w/ tagged and min score given
<?php
/*
* uri param to this "web script"
* q = tag values split by a semicol
* minscore = min score (int)
*
* it's a lil bit nasty, but can modify so easy, the same to turn into a shell script
*/
$url = "http://api.stackoverflow.com/1.0/questions?tagged=".urlencode($_GET["q"]);
$str = array();
$max = 30;
$minscore = isset($_GET["minscore"]) ? $_GET["minscore"] : 0;
for ($i = 1; $i < $max; $i++) {
$temp = "";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "$url&page=$i");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch,CURLOPT_ENCODING,'gzip');
$temp = curl_exec($ch);
curl_close($ch);
$json = json_decode($temp);
foreach($json->questions as $q)
if($q->score > $_GET["minscore"])
echo "<p>[ $q->score ] $q->title <a href='http://stackoverflow.com/questions/".$q->question_id."'>open</a></p>";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment