This repository has been archived by the owner on Feb 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
session_start(); | ||
|
||
// Our configuration, edit it to set your API credentials | ||
require_once('config.php'); | ||
|
||
// OAuth library | ||
require_once('oauth.php'); | ||
|
||
// Flattr REST library | ||
require_once('flattr_rest.php'); | ||
|
||
function loadToken() | ||
{ | ||
return array($_SESSION['flattr_access_token'], $_SESSION['flattr_access_token_secret']); | ||
} | ||
|
||
// Load token | ||
list($token, $token_secret) = loadToken(); | ||
|
||
// Setup a new client | ||
$flattr = new Flattr_Rest(APP_KEY, APP_SECRET, $token, $token_secret); | ||
|
||
// Did we succeed? | ||
if ( $flattr->error() ) | ||
{ | ||
die( 'Error ' . $flattr->error() ); | ||
} | ||
|
||
// Get the thing list, using a search query | ||
if (isset($_GET['q'])) | ||
{ | ||
$things = $flattr->getSearchThingList($_GET['q']); | ||
} | ||
else | ||
{ | ||
$things = array(); | ||
echo 'ok didnt search for anything, listnening your things insteed'; | ||
$things = $flattr->getThingList(); | ||
} | ||
|
||
?> | ||
<p> | ||
found <?php echo count($things) ?> things. | ||
</p> | ||
<?php foreach ( $things as $thing ): ?> | ||
<p> | ||
Title: <?php echo $thing['title'] ?> | ||
</p> | ||
<?php endforeach ?> | ||
|
||
<h2> Search for things</h2> | ||
<form method="get" action="search.php"> | ||
<div> | ||
<input type="text" name="q" value="the search query"> | ||
</div> | ||
<div> | ||
<input type="submit"> | ||
</div> | ||
</form> |
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