Example #1
0
 public function testItemsGetInfoMultiNotThere()
 {
     $coreClient = new RingsideRestClient($this->fbClient);
     $coreClient->items_setInfo(123, 'http://localhost/foo.jpg', 'http://localhost/foo.html');
     $coreClient->items_setInfo(345, 'http://localhost/bar.jpg', 'http://localhost/bar.html');
     $info = $coreClient->items_getInfo(array(123, 234));
     $this->assertTrue(is_array($info), "Expected an array of item info, got {$info}");
     $this->assertEquals(1, sizeof($info));
     $this->assertEquals('http://localhost/foo.jpg', $info[0]['url']);
     $this->assertEquals('http://localhost/foo.html', $info[0]['refurl']);
 }
 function doEndTag($application, $parentHandler, $args)
 {
     $this->loadTopicsAndSuggestions($application);
     $lasttopic = '';
     $count = 0;
     if (!empty($this->suggestions)) {
         $iids = array();
         foreach ($this->suggestions as $suggestion) {
             $topic = $suggestion['topic'];
             if (!isset($args['topic']) || $args['topic'] == 'all' || $args['topic'] == $topic) {
                 try {
                     $names = $application->getClient()->users_getInfo($suggestion['uid'], "first_name");
                     $name = $names[0];
                     $firstname = $name['first_name'];
                 } catch (Exception $e) {
                     $firstname = 'Friend of Friend';
                 }
                 // Checking for topic switches
                 if ($topic != $lasttopic) {
                     if ($count > 0) {
                         echo '</table>';
                     }
                     echo '<br />';
                     echo '<table border="0" width="500px" cellpadding="5">';
                     $colspan = isset($this->style) ? 3 : 2;
                     echo '  <tr><td width="500px" colspan="' . $colspan . '" bgcolor="#f7931d">Topic: ' . $topic . '</td></tr>';
                     $lasttopic = $topic;
                 }
                 echo '  <tr>';
                 if (isset($this->style)) {
                     $rest = new RingsideRestClient($application->getClient());
                     $iids[] = $suggestion['sid'];
                     $rest->items_setInfo($suggestion['sid'], 'trail6', 'trail6', null);
                     //Now get ratings
                     $ratings = array();
                     if (count($iids) > 0) {
                         $ratings = $rest->ratings_get($iids);
                         if (!$ratings) {
                             $ratings = array();
                         }
                     }
                     $yes = 'black';
                     $no = 'black';
                     foreach ($ratings as $rating) {
                         $iid = $rating['iid'];
                         if ($iid == $suggestion['sid']) {
                             $vote = $rating['vote'];
                             if ($vote == 1) {
                                 $yes = 'green';
                             } else {
                                 $no = 'red';
                             }
                         }
                     }
                     $vote_string = '<a href="index.php?action=rate&vote=1&iid=' . $suggestion['sid'] . '"><font color="' . $yes . '">yes</font></a>|<a href="index.php?action=rate&vote=0&iid=' . $suggestion['sid'] . '"><font color="' . $no . '">no</font></a> ';
                     echo '      <td width="5%" bgcolor="#eeeeee">' . $vote_string . '</td>';
                 }
                 echo '      <td width="30%" bgcolor="#fdc589">' . $suggestion['suggestion'] . '</td>';
                 echo '      <td width="65%" bgcolor="#eeeeee">posted by ' . $firstname . ' at ' . $suggestion['created'] . '</td>';
                 echo '  </tr>';
                 $count++;
             }
         }
     }
     if ($count > 0) {
         echo '</table>';
     }
 }
Example #3
0
/**
 * Queries for a list of suggestions and then includes the list page
 *
 * @param int $topic Topic ID, optional parameter.
 */
function showSuggestions(RingsideRestClient $rest, $uid)
{
    $friends = $rest->delegate->friends_get();
    $friends[] = $uid;
    $suggestions = SuggestionUtils::getSuggestions($friends);
    // Now get ratings
    $iids = array();
    foreach ($suggestions as $suggestion) {
        $iids[] = $suggestion['sid'];
        $rest->items_setInfo($suggestion['sid'], 'trail4', 'trail4', null);
    }
    $ratings = array();
    if (sizeof($iids) > 0) {
        $ratings = $rest->ratings_get($iids);
    }
    include_once 'list.php';
}
Example #4
0
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 ******************************************************************************/
// Include the ringside client libraries
require_once 'config.php';
require_once 'SuggestionUtils.php';
include_once 'ringside/api/clients/RingsideApiClients.php';
include_once 'ringside/api/clients/RingsideRestClient.php';
// Get the ringside client
RingsideApiClientsConfig::$serverUrl = Config::$ringsideApi;
RingsideApiClientsConfig::$webUrl = Config::$ringsideWeb;
$ringsideClient = new RingsideApiClients(Config::$api_key, Config::$secret);
// Make sure the user is logged in and get the UID
$userid = $ringsideClient->require_login();
// Instantiate the rest client, this is for the ratings api in extension apps
$rest = new RingsideRestClient($ringsideClient->api_client);
$name = $rest->delegate->users_getInfo($userid, "first_name");
// Show the dashboard
?>
<fb:dashboard>
	<fb:action href="index.php?action=list">View Suggestions</fb:action>
	<fb:create-button href="index.php?action=add">Create a Suggestion</fb:create-button>
</fb:dashboard>
<?php 
// Say hi to the user, but let's use an fbml tag, just as another example of using fbml
// instead of html
echo '<fb:explanation><fb:message>Suggestions Demo Application</fb:message>Welcome ' . $name[0]['first_name'] . '</fb:explanation>';
// Control what template we load
// Templates are just php files with fbml/html in them.  We use php so we can perform variable substitution
// loop through data, etc...  Normal template language stuff without the template language!
if (isset($_REQUEST['action'])) {
Example #5
0
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 ******************************************************************************/
require_once('ringside/core/client/RingsideRestClient.php');
require_once('config.php');

$server_url = "http://api.facebook.com/restserver.php";
$web_url = 'http://www.facebook.com';
try {
require_once('ringside/api/clients/RingsideApiClients.php');
$fb = new RingsideApiClients($api_key, $secret, $web_url, $server_url);
$ringside = new RingsideRestClient($fb->api_client);

$loggedinuser = $fb->require_login();
$fb->api_client->friends_get();

	$ringside->items_setInfo('testitem', RingsideRestClient::$server_url, 'http://'.$_SERVER['HTTP_HOST']);
	$item = $ringside->items_getInfo('testitem');
	if ($item) {
?>Test Passed<?
$ringside->items_remove('testitem');
	} else {
?>Test FAILED<?
	}
} catch ( Exception $e ) {
?>Test EXCEPTION<br><pre><?php
echo $e->getMessage()."\n";