Esempio n. 1
0
 public function execute()
 {
     $appService = Api_ServiceFactory::create('AppService');
     $domainService = Api_ServiceFactory::create('DomainService');
     $aid = false;
     if (null != $this->m_aid) {
         $aid = $this->m_aid;
     } elseif (null != $this->m_appApiKey) {
         $aid = $appService->getNativeIdByApiKey($this->m_appApiKey);
     } elseif (null != $this->m_canvasName) {
         $aid = $appService->getNativeIdByProperty('canvas_url', $this->m_canvasName);
     }
     if (false !== $aid) {
         // TODO: Is this the right way to check for admin users?
         if ($this->getUserId() > 0 && !Api_Bo_App::checkUserOwnsApp($this->getUserId(), $aid)) {
             throw new Exception('Cannot query for app keys: permission denied');
         }
         $keyService = Api_ServiceFactory::create('KeyService');
         $keysets = $keyService->getAllKeysets($aid);
         $rkeys = array();
         foreach ($keysets as $ks) {
             $arr = array();
             $dkeys = $keyService->getKeyset($ks['domain_id'], $ks['domain_id']);
             $domainKey = $dkeys['api_key'];
             $arr['network_id'] = $domainKey;
             $arr['api_key'] = $ks['api_key'];
             $arr['secret'] = $ks['secret'];
             $rkeys[] = $arr;
         }
         $response = array('resp' => $rkeys);
         return $response;
     }
     throw new Exception("Could not find app with api key '{$this->m_appApiKey}' on network '{$this->m_nid}'");
 }
 public function testService()
 {
     $upService = Api_ServiceFactory::create('UserProfileService');
     $this->assertTrue($upService != NULL);
     $this->assertTrue($upService->isSupported('activities'));
     $this->assertFalse($upService->isSupported('goats'));
 }
Esempio n. 3
0
 public function execute()
 {
     $appService = Api_ServiceFactory::create('AppService');
     $appId = $appService->getNativeIdByApiKey($this->m_apiKey);
     $this->setSessionValue(self::SESSION_APP_ID, $appId);
     $this->checkDefaultApp();
     $sid = $this->getSessionValue(self::SESSION_ID);
     $this->setSessionValue(self::SESSION_TYPE, self::SESSION_TYPE_VALUE_SESS);
     $this->setSessionValue(self::SESSION_APPROVED, true);
     if ($this->m_infinite === true) {
         //         Session::mark_infinite( $sid );
         $this->setSessionValue(self::SESSION_INFINITE, 'true');
         $this->setSessionValue(self::SESSION_EXPIRES, self::SESSION_EXPIRES_VALUE_NEVER);
     } else {
         $this->setSessionValue(self::SESSION_INFINITE, 'false');
         $this->setSessionValue(self::SESSION_EXPIRES, time() + 5 * 60);
     }
     $this->setSessionValue(self::SESSION_CALL_ID, 0);
     $this->setSessionValue(self::SESSION_APP_ID, $appId);
     $this->setSessionValue(self::SESSION_API_KEY, $this->m_apiKey);
     $this->setSessionValue(self::SESSION_USER_ID, $this->m_uid);
     $this->setSessionValue(self::SESSION_NETWORK_ID, $this->m_networkKey);
     $this->m_nid = $this->m_networkKey;
     $response = array();
     $response[self::RESPONSE_SESSION_KEY] = $sid . '-ringside';
     $response[self::RESPONSE_EXPIRES] = $this->getSessionValue(self::SESSION_EXPIRES);
     $response[self::RESPONSE_USER_ID] = $this->getSessionValue(self::SESSION_USER_ID);
     return $response;
 }
 public function testExecute()
 {
     $uid = 17001;
     $name = 'superapp5372';
     $oldApiKey = 'test_case_key-81753';
     $oldSecret = 'nnn283f238h';
     $appProps = array();
     $keyService = Api_ServiceFactory::create('KeyService');
     $domainService = Api_ServiceFactory::create('DomainService');
     $localDomainId = $domainService->getNativeIdByName('Ringside');
     $ids = $keyService->getKeyset($localDomainId, $localDomainId);
     $domainKey = $ids['api_key'];
     $this->assertNotNull($domainKey);
     $appService = Api_ServiceFactory::create('AppService');
     $appId = $appService->createApp($name, $oldApiKey, $oldSecret, $appProps);
     Api_Dao_App::setAppOwner($uid, $appId);
     $params = array('app_api_key' => $oldApiKey);
     $newApiKey = '237825y235nn';
     $newSecret = '328752hannafds';
     $kprops = array();
     $kprops[] = array('network_id' => $domainKey, 'api_key' => $newApiKey, 'secret' => $newSecret);
     $params = array('app_id' => $appId, 'keys' => json_encode($kprops));
     $api = $this->initRest(new AdminSetAppKeys(), $params, $uid, $appId);
     $this->assertTrue($api->execute());
     $params = array('app_api_key' => $newApiKey);
     $api = $this->initRest(new AdminGetAppKeys(), $params, $uid, $appId);
     $resp = $api->execute();
     $this->assertEquals(1, count($resp['resp']));
     $this->assertEquals($newApiKey, $resp['resp'][0]['api_key']);
     $this->assertEquals($newSecret, $resp['resp'][0]['secret']);
     $appService->deleteApp($appId);
     Api_Dao_App::removeAppOwner($uid, $appId);
 }
Esempio n. 5
0
 /**
  * Execute the auth.createToken method
  */
 public function execute()
 {
     $response = array();
     //		$response['auth_token'] = $auth_token = session_id();
     // TODO what is this change going to bust?
     // FIXME: This is an odd statment and $auth_token is never used!  Should it be removed?
     $response[self::RESPONSE_AUTH_TOKEN] = $auth_token = $this->getSessionValue(self::SESSION_ID);
     $this->setSessionValue(self::SESSION_API_KEY, $this->m_apiKey);
     if ($this->m_infinite) {
         //         error_log("auth_token $auth_token will be infinite for ".$this->m_apiKey);
         $this->setSessionValue(self::SESSION_INFINITE, 'true');
     }
     $this->setSessionValue(self::SESSION_EXPIRES, time() + 5 * 60);
     $this->setSessionValue(self::SESSION_TYPE, self::SESSION_TYPE_VALUE_AUTH);
     if ($this->getNetworkId() !== null) {
         $this->setSessionValue(self::SESSION_NETWORK_ID, $this->getNetworkId());
     }
     $appService = Api_ServiceFactory::create('AppService');
     $aid = $appService->getNativeIdByApiKey($this->m_apiKey);
     if ($aid == NULL || $aid === false) {
         error_log('Attempt to create auth token from unknown app: ' . $this->m_apiKey);
         throw new OpenFBAPIException('Invalid api key', FB_ERROR_CODE_API_KEY_NOT_ASSOCIATED_WITH_APP);
     }
     $this->setSessionValue(self::SESSION_APP_ID, $aid);
     return $response;
 }
Esempio n. 6
0
 public static function destroy()
 {
     $domainService = Api_ServiceFactory::create('DomainService');
     $localDomainId = $domainService->getNativeIdByName('Ringside');
     if ($localDomainId != NULL) {
         $domainService->deleteDomain($localDomainId);
     }
 }
 public function testAppKeysets()
 {
     $keyService = Api_ServiceFactory::create('KeyService');
     $this->assertTrue($keyService != NULL);
     //ficticious ids
     $appId = 1001;
     $domainId1 = 1024;
     $domainId2 = 12875;
     $domainId3 = 666;
     //mark of the beast
     $apiKey1 = '3883275772dxxxx';
     $secret1 = '8235uiuasd23nnn';
     $apiKey2 = '3983hhnn3nnn2';
     $secret2 = 'x98275majf93';
     $apiKey3 = 'qht278nnf9a0';
     $secret3 = '00382xxnnah';
     //test createKeyset
     $this->assertTrue($keyService->createKeyset($appId, $domainId1, $apiKey1, $secret1));
     $this->assertTrue($keyService->createKeyset($appId, $domainId2, $apiKey2, $secret2));
     $this->assertTrue($keyService->createKeyset($appId, $domainId3, $apiKey3, $secret3));
     //test uniqueness
     $this->assertFalse($keyService->isUnique($apiKey1, $secret1));
     $this->assertFalse($keyService->isUnique($apiKey2, $secret2));
     $this->assertFalse($keyService->isUnique($apiKey3, $secret3));
     $this->assertTrue($keyService->isUnique('goats goats goats', 'asdf123'));
     //test getKeyset
     $kset = $keyService->getKeyset($appId, $domainId1);
     $this->assertEquals($appId, $kset['entity_id']);
     $this->assertEquals($domainId1, $kset['domain_id']);
     $this->assertEquals($apiKey1, $kset['api_key']);
     $this->assertEquals($secret1, $kset['secret']);
     $kset = $keyService->getKeyset($appId, $domainId2);
     $this->assertEquals($appId, $kset['entity_id']);
     $this->assertEquals($domainId2, $kset['domain_id']);
     $this->assertEquals($apiKey2, $kset['api_key']);
     $this->assertEquals($secret2, $kset['secret']);
     $kset = $keyService->getKeyset($appId, $domainId3);
     $this->assertEquals($appId, $kset['entity_id']);
     $this->assertEquals($domainId3, $kset['domain_id']);
     $this->assertEquals($apiKey3, $kset['api_key']);
     $this->assertEquals($secret3, $kset['secret']);
     //test getIds
     $ids = $keyService->getIds($apiKey1);
     $this->assertEquals($appId, $ids['entity_id']);
     $this->assertEquals($domainId1, $ids['domain_id']);
     //test getAllKeysets
     $ksets = $keyService->getAllKeysets($appId);
     $this->assertNotNull($ksets);
     $this->assertEquals(3, count($ksets));
     //test deleteKeyset
     $keyService->deleteKeyset($appId, $domainId2);
     $ksets = $keyService->getAllKeysets($appId);
     $this->assertNotNull($ksets);
     $this->assertEquals(2, count($ksets));
     $keyService->deleteAllKeysets($appId);
     $ksets = $keyService->getAllKeysets($appId);
     $this->assertNull($ksets);
 }
 public function tearDown()
 {
     Api_ServiceFactory::create('KeyService')->deleteKeyset($this->aDomain["id"], $this->aDomain["id"]);
     Api_ServiceFactory::create('AppService')->deleteApp($this->anApp["id"]);
     $this->domainService->deleteDomain($this->aDomain["id"]);
     unset($this->anApp);
     unset($this->aDomain);
     unset($this->domainService);
 }
Esempio n. 9
0
 /**
  * Returns the friends for the logged in user for their current domain
  *
  * @return array
  */
 public function execute()
 {
     //error_log("**************current network is ". $this->getNetworkId());
     $betterFriendsService = Api_ServiceFactory::create('BetterFriendsService');
     $friends = $betterFriendsService->get($this->getRequiredApiParam('domain_key'), $this->getRequiredApiParam('owner_uid'));
     if (empty($friends)) {
         $response['uid'] = '';
     } else {
         $response['uid'] = $friends;
     }
     return $response;
 }
Esempio n. 10
0
 public function execute()
 {
     $response = array();
     $appService = Api_ServiceFactory::create('AppService');
     $keyService = Api_ServiceFactory::create('KeyService');
     // for a given application generate and store its API and PRIVATE KEY.
     $newApiKey = $response['api_key'] = hash('md5', $this->name . ' ' . $time() . ' ' . $rand());
     $newSecret = $response['private_key'] = hash('md5', $tihs->name . ' ' . $rand() . ' ' . $time());
     $appId = $appService->getNativeIdByApiKey($this->api_key);
     $ids = $keyService->getIds($this->getNetworkId());
     $domainId = $ids['entity_id'];
     $keyService->updateKeyset($appId, $domainId, $newApiKey, $newSecret);
     return $response;
 }
Esempio n. 11
0
 public function execute()
 {
     $appService = Api_ServiceFactory::create('AppService');
     $keyService = Api_ServiceFactory::create('KeyService');
     //check to make sure name isn't already taken
     $ids = $appService->getNativeIdsByProperty('name', $this->m_appName);
     if ($ids != NULL && count($ids) > 0) {
         throw new OpenFBAPIException("An application named '" . $this->m_appName . "' already exists.");
     }
     //create unique API and secret keys
     $apiKey = "";
     $secret = "";
     $uniqueKeys = false;
     while (!$uniqueKeys) {
         //create API key
         for ($k = 0; $k < 32; $k++) {
             $apiKey .= dechex(mt_rand(1, 15));
         }
         //create secret
         for ($k = 0; $k < 32; $k++) {
             $secret .= dechex(mt_rand(1, 15));
         }
         //check for uniqueness
         $uniqueKeys = $keyService->isUnique($apiKey, $secret);
     }
     //create icon url
     $infoApi = new AdminGetServerInfo($this->getUserId(), array(), $this->getSession());
     $sinfo = $infoApi->execute();
     $wurl = $sinfo['result']['web_url'];
     if ($wurl == 'http://:') {
         $wurl = 'http://localhost:8080';
     }
     $iconUrl = $wurl . '/images/icon-app-default.png';
     //create app
     $appProps = array('isdefault' => 0, 'icon_url' => $iconUrl);
     $id = $appService->createApp($this->m_appName, $apiKey, $secret, $appProps);
     //return response
     $response = array();
     if ($id !== false) {
         $response["app"] = array();
         $response['app']['application_id'] = $id;
         $response["app"]["name"] = $this->m_appName;
         $response["app"]["api_key"] = $apiKey;
         $response["app"]["secret"] = $secret;
     } else {
         error_log('Error creating application');
     }
     return $response;
 }
Esempio n. 12
0
 public function execute()
 {
     if (!Api_Dao_App::checkUserOwnsApp($this->getUserId(), $this->m_appId)) {
         throw new Exception('Cannot query for app keys, user does not own app.');
     }
     $domainService = Api_ServiceFactory::create('DomainService');
     $keyService = Api_ServiceFactory::create('KeyService');
     foreach ($this->m_keys as $keyset) {
         $domainKey = $keyset['network_id'];
         $domainId = $domainService->getNativeIdByApiKey($domainKey);
         $newApiKey = $keyset['api_key'];
         $newSecret = $keyset['secret'];
         $keyService->updateKeyset($this->m_appId, $domainId, $newApiKey, $newSecret);
     }
     return true;
 }
Esempio n. 13
0
 public function testStuff()
 {
     $appService = Api_ServiceFactory::create('AppService');
     $this->assertTrue($appService != NULL);
     $props = $this->getTestAppProps();
     $name = 'mynewapp22';
     $apiKey = '3821857235nnd';
     $secret = 'adf2893fh232323';
     //test create
     $appId = $appService->createApp($name, $apiKey, $secret, $props);
     //test getAllApps
     $allApps = $appService->getAllApps();
     //error_log(var_export($allApps,true));
     $this->assertTrue(count($allApps) > 0);
     $this->assertTrue(array_key_exists("canvas_url", $allApps[0]));
     //test query by property
     $ids = $appService->getNativeIdsByProperty('canvas_url', $props['canvas_url']);
     $this->assertNotNull($ids);
     $this->assertEquals(1, count($ids));
     $this->assertEquals($appId, $ids[0]);
     //test exists
     $this->assertTrue($appService->appExists($appId));
     //test query by api key
     $id = $appService->getNativeIdByApiKey($apiKey);
     $this->assertEquals($appId, $id);
     //test getApp
     $app = $appService->getApp($appId);
     $this->assertEquals($name, $app['name']);
     foreach ($app as $aname => $aval) {
         if (!in_array($aname, array('id', 'created', 'modified', 'name'))) {
             $this->assertEquals($props[$aname], $aval);
         }
     }
     //test update
     $newAuthor = 'Goats McGoat';
     $newProps = array('author' => $newAuthor);
     $appService->updateApp($appId, $newProps);
     $app = $appService->getApp($appId);
     $this->assertEquals($newAuthor, $app['author']);
     //test delete
     $appService->deleteApp($appId);
     //test create with id specified
     $appId = 44;
     $createdId = $appService->createApp($name, $apiKey, $secret, $props, $appId);
     $this->assertEquals($appId, $createdId);
     $appService->deleteApp($appId);
 }
Esempio n. 14
0
 public function execute()
 {
     $appId = NULL;
     $appService = Api_ServiceFactory::create('AppService');
     //check to make sure name isn't already taken
     if (null != $this->m_aid) {
         $appId = $this->m_aid;
     } elseif (null != $this->m_appApiKey) {
         $appId = $appService->getNativeIdByApiKey($this->m_appApiKey);
     } elseif (null != $this->m_canvasName) {
         $ids = $appService->getNativeIdByProperty('canvas_url', $this->m_canvasName);
         if (count($ids) > 0) {
             $appId = $ids[0];
         }
     }
     $appService->deleteApp($appId);
     return true;
 }
Esempio n. 15
0
 public function testExecute()
 {
     $uid = 17001;
     $name = 'superapp5372';
     $apiKey = 'test_case_key-81753';
     $secret = 'nnn283f238h';
     $appProps = array();
     $appService = Api_ServiceFactory::create('AppService');
     $appId = $appService->createApp($name, $apiKey, $secret, $appProps);
     Api_Dao_App::setAppOwner($uid, $appId);
     $params = array('app_api_key' => $apiKey);
     $api = $this->initRest(new AdminGetAppKeys(), $params, $uid, $appId);
     $resp = $api->execute();
     $this->assertEquals(1, count($resp['resp']));
     $this->assertEquals($apiKey, $resp['resp'][0]['api_key']);
     $this->assertEquals($secret, $resp['resp'][0]['secret']);
     $appService->deleteApp($appId);
     Api_Dao_App::removeAppOwner($uid, $appId);
 }
Esempio n. 16
0
 /**
  * Execute the api call to get user app list.
  */
 public function execute()
 {
     //$ret = Api_Bo_App::getAllApplications();
     // networkID cannot be set if we are returning all apps from a domain
     // It's a security risk to accept domain keys via the API parameters
     if ($this->getNetworkId()) {
         $domainService = Api_ServiceFactory::create('DomainService');
         $ret = $domainService->getAppsByApiKey($this->getNetworkId());
     } else {
         $appService = Api_ServiceFactory::create('AppService');
         $ret = $appService->getAllApps();
     }
     $response = array();
     if (empty($ret)) {
         $response['apps'] = array();
     } else {
         $response['apps'] = $ret;
     }
     return $response;
 }
Esempio n. 17
0
 public function getAppsByApiKey($apiKey)
 {
     if ($apiKey == null) {
         error_log("No ApiKey was sent to the getAppsByApiKey method");
         return null;
     }
     $domain_id = $this->getNativeIdByApiKey($apiKey);
     $keyService = Api_ServiceFactory::create('KeyService');
     $keys = $keyService->getAllKeysetsByDomainId($domain_id);
     $appService = Api_ServiceFactory::create('AppService');
     if (count($keys > 0)) {
         foreach ($keys as $key) {
             $apps[] = $appService->getApp($key['entity_id'], $key['domain_id']);
         }
         if (count($apps) > 0) {
             return $apps;
         }
     } else {
         return null;
     }
 }
Esempio n. 18
0
 /**
  * Returns an array of all app fbml blocks
  * formatted for display.
  * $location enum(narrow|wide) indicates the style to be used when fbml is returned
  * $arryExcludeAppNames is an array of app names which should not appear in the list
  * 
  */
 function getAllFormattedHtmlForUserOpenSocialApps($location = "narrow", $arryExcludeAppNames = null)
 {
     $userAppList = Api_Bo_App::getApplicationListByUserId($this->uid);
     $this->debug("******************** DUMPING OS userAppList for {$this->uid}" . " which is " . count($userAppList) . " apps");
     $aggregateFbml = "";
     $fbmlArry = array();
     if (!empty($userAppList)) {
         foreach ($userAppList as $index => $appInfo1) {
             $appInfo = $appInfo1['RingsideApp'];
             $this->debug("Processing " . $appInfo['name'] . " " . $appInfo['app_id']);
             $this->debug("{$appInfo1}=" . var_export($appInfo1, true));
             //$returnedFbml=$this->getFbmlForApp($appInfo1['app_id'],$this->uid);
             $app_id = $appInfo1['app_id'];
             $app_name = $appInfo['name'];
             $enabled = true;
             // Don't show this app if it is not open social
             if ($appInfo['canvas_type'] != 2) {
                 $enabled = false;
                 $this->debug("{$app_name} rejected as not open social.");
             }
             if ($enabled) {
                 //$app_appBlock=$this->getFormatedFbmlFromAppName($app_name,$location,true,$returnedFbml);
                 //$fbmlArry=array_merge($fbmlArry,$app_appBlock);
                 $block = array("<div id='app-{$app_name}-header' class='wide_app_header'> ");
                 $block[] = $app_name;
                 //$block[]="<div style='float: right;' ><form id='formmove' name='formmove'  method='post' ><input name='action' type='hidden' value='saveColChange'/><input name='appname' type='hidden' value='$app_name'/><a onClick='form.submit();' href=''> [move] </a></form></div>";
                 $block[] = "</div>";
                 $frameParams = $_REQUEST;
                 $callbackQuery = http_build_query($frameParams);
                 $owner_id = $_REQUEST['id'];
                 if ($owner_id == '') {
                     $owner_id = $this->uid;
                 }
                 // Get api_key
                 $keyService = Api_ServiceFactory::create('KeyService');
                 $domainService = Api_ServiceFactory::create('DomainService');
                 $domainId = $domainService->getNativeIdByName('Ringside');
                 $app_keysArray = $keyService->getKeyset($app_id, $domainId);
                 $app_keys = $app_keysArray;
                 /*
                 		      	 $app_keysArray=Api_Bo_App::getUsersAppKeys($this->uid,$app_id);
                 		      	 $app_keys=$app_keysArray[0];
                 		      	 $this->debug(var_export($app_keysArray,true));
                 		      	 foreach($app_keysArray as $testApp_keys){
                 		      	 	if($testApp_keys['network_id']==$socialApiKey){
                 		      	 		$app_keys=$testApp_keys;
                 		      	 	}
                 		      	 }
                 		      	 $app_keys=$app_keysArray[0];
                 */
                 $this->debug("{$app_keys}=" . var_export($app_keys, true));
                 $social_session = new RingsideSocialSession();
                 $social_session->addApiSessionKey($app_keys['api_key'], $app_keys['secret']);
                 $this->debug("Building Social Session with " . $app_keys['api_key'] . " and " . $app_keys['secret']);
                 $osGadgetUrl = RingsideSocialConfig::$socialRoot . '/gadgets/ifr?view=profile&synd=ringside&fb_sig_api_key=' . $app_keys['api_key'] . '&fb_sig_owner_id=' . $owner_id . '&url=' . urlencode($appInfo['callback_url']) . '&social_session_key=' . $social_session->getSessionKey();
                 $this->debug("osGadgetUrl= {$osGadgetUrl}");
                 $block[] = '<iframe src="' . $osGadgetUrl . '" height="400" width="450"></iframe>';
                 $fbmlArry = array_merge($fbmlArry, $block);
             }
         }
     }
     return $fbmlArry;
 }
Esempio n. 19
0
 /**
  * If this is a cross app call, one app trying to execute something on another application
  * validate that the calling application is a DEFAULT enabled application as they should be the
  * only ones allowed to do this.
  *
  * @param integer $aid
  * @return true
  * @throws OpenFBApiException if the calling app is not allowed to make the call.
  */
 public function checkDefaultApp($aid = null)
 {
     // TODO: SECURITY: This disables security on app-to-app requests!
     return;
     /*
      * You can only cross check application information if
      * the calling application is a default application
      */
     $tad = $this->getAppId();
     error_log("Invoking API as {$tad} against application {$aid}");
     if ($aid == null || $aid != $tad) {
         $appService = Api_ServiceFactory::create('AppService');
         if (null != $tad) {
             // If a domain is calling this method, it should work
             $callingApp = $appService->getApp($tad);
             if ($callingApp == NULL || empty($callingApp)) {
                 throw new OpenFBAPIException("Can not load calling application information ({$aid},{ {$tad} })", FB_ERROR_CODE_UNKNOWN_ERROR);
             }
             $isDefault = $callingApp['isdefault'];
             if ($isDefault == 0) {
                 error_log("Application {$tad} cannot get information on application {$aid}");
                 throw new OpenFBAPIException(FB_ERROR_MSG_GRAPH_EXCEPTION, FB_ERROR_CODE_GRAPH_EXCEPTION);
             }
         }
     }
     return true;
 }
 public function setUp()
 {
     $this->betterFriendsService = Api_ServiceFactory::create('betterFriendsService');
 }
Esempio n. 21
0
 public static function destroyApps()
 {
     $appService = Api_ServiceFactory::create('AppService');
     $appService->deleteApp(11000);
     $appService->deleteApp(8100);
     $appService->deleteApp(8101);
     $appService->deleteApp(8102);
     $appService->deleteApp(17100);
     $appService->deleteApp(34000);
     $appService->deleteApp(34001);
     $appService->deleteApp(36000);
     $appService->deleteApp(36110);
     $appService->deleteApp(36060);
     $appService->deleteApp(35000);
     $appService->deleteApp(35001);
     $appService->deleteApp(3100);
     $appService->deleteApp(6100);
     $appService->deleteApp(7100);
     $appService->deleteApp(7101);
     $appService->deleteApp(7102);
     $appService->deleteApp(4100);
     $appService->deleteApp(11001);
     $appService->deleteApp(16100);
 }
Esempio n. 22
0
 public static function create($implClass = null)
 {
     return Api_ServiceFactory::create('Api_Bo_NotificationService', 'Api_Bo_NotificationServiceImpl', $implClass);
 }
Esempio n. 23
0
 public function execute()
 {
     $appService = Api_ServiceFactory::create('AppService');
     $aid = false;
     if (null != $this->m_aid) {
         $aid = $this->m_aid;
     } elseif (null != $this->m_apiKey) {
         $aid = $appService->getNativeIdByApiKey($this->m_apiKey);
     } elseif (null != $this->m_canvasName) {
         $ids = $appService->getNativeIdsByProperty('canvas_url', $this->m_canvasName);
         if ($ids != NULL && count($ids) > 0) {
             $aid = $ids[0];
         }
     }
     if (false !== $aid) {
         $this->checkDefaultApp($aid);
         $dbProps = array();
         foreach ($this->m_properties as $name => $val) {
             if (isset(self::$map[$name])) {
                 $dbName = self::$map[$name];
                 $dbProps[$dbName] = $val;
             } else {
                 throw new OpenFBAPIException("No such property '{$name}'");
             }
         }
         $appService->updateApp($aid, $dbProps);
         return true;
     }
     throw new OpenFBAPIException("Could not find a valid application to update");
 }
Esempio n. 24
0
 public function deleteApp($appId)
 {
     $keyService = Api_ServiceFactory::create('KeyService');
     $keyService->deleteAllKeysets($appId);
     $q = new Doctrine_Query();
     $q->select('*');
     $q->from('RingsideApp');
     $q->where("id={$appId}");
     $res = $q->execute();
     if (count($res) > 0) {
         if (!$res[0]->delete()) {
             throw new Exception("[AppServiceImpl] could not delete app with id={$appId}");
         }
     }
 }
Esempio n. 25
0
 /**
  * Process API request to get an applications properties.
  *
  */
 public function execute()
 {
     $appService = Api_ServiceFactory::create('AppService');
     $response = array();
     if ($this->m_canvasName != null) {
         $ids = $appService->getNativeIdsByProperty('canvas_url', $this->m_canvasName);
         if ($ids == NULL || count($ids) == 0) {
             throw new OpenFBAPIException("No such application known, canvas name is '{$this->m_canvasName}'", FB_ERROR_CODE_NO_APP);
         }
         $this->m_aid = $ids[0];
     } else {
         if ($this->m_apiKey != null) {
             $id = $appService->getNativeIdByApiKey($this->m_apiKey);
             if ($id == NULL) {
                 throw new OpenFBAPIException("No such application known, API key is '{$this->m_apiKey}' on '{$this->m_nid}' network.", FB_ERROR_CODE_NO_APP);
             }
             $this->m_aid = $id;
         }
     }
     /*
      * You can only cross check application information if
      * the calling application is a default application
      */
     // TODO: SECURITY: This disables cross-app calling security if uncommented!
     if (false && $this->m_aid != $this->getAppId()) {
         $isDefault = $this->checkDefaultApp($this->m_aid);
         if (!$isDefault) {
             throw new OpenFBAPIException('Application with id ' . $this->getAppId() . ' is not a default app: ' . FB_ERROR_MSG_GRAPH_EXCEPTION, FB_ERROR_CODE_GRAPH_EXCEPTION);
         }
     }
     $app = $appService->getApp($this->m_aid);
     $domainService = Api_Bo_DomainService::create();
     $did = $domainService->getNativeIdByApiKey($this->m_nid);
     $keyService = Api_Bo_KeyService::create();
     $keyset = $keyService->getKeyset($this->m_aid, $did);
     $app['api_key'] = isset($keyset['api_key']) ? $keyset['api_key'] : '';
     $app['secret_key'] = isset($keyset['secret']) ? $keyset['secret'] : '';
     $response = array();
     if ($app != NULL) {
         foreach ($this->m_properties as $prop) {
             if (!isset(self::$map[$prop])) {
                 throw new OpenFBAPIException(FB_ERROR_MSG_PARAMETER_MISSING, FB_ERROR_CODE_PARAMETER_MISSING);
             }
             $key = self::$map[$prop];
             if (!isset($app[$key])) {
                 $response[$prop] = '';
             } else {
                 $response[$prop] = $app[$key];
             }
         }
     }
     return array('result' => json_encode($response));
 }
Esempio n. 26
0
 /**
  * Queries the friends and users table to match the query given.
  * If no query is provided it returns all friends.
  *
  * @return array
  */
 public function execute()
 {
     $betterFriendsService = Api_ServiceFactory::create('BetterFriendsService');
     return $betterFriendsService->remove($this->getRequiredApiParam('domain_key'), $this->getRequiredApiParam('owner_uid'), $this->getRequiredApiParam('target_uid'));
 }
Esempio n. 27
0
 /**
  * Creates a new instance of the UserProfile service.
  *
  * @param string $implClass
  * @return Api_Bo_UserProfileService
  */
 public static function create($implClass = null)
 {
     return Api_ServiceFactory::create('Api_Bo_UserProfileService', self::DEFAULT_USERPROFILE_SERVICE, $implClass);
 }
Esempio n. 28
0
 public static function installApps()
 {
     include 'LocalSettings.php';
     $appService = Api_ServiceFactory::create('AppService');
     $props = array();
     $props['callback_url'] = '';
     $props['canvas_url'] = 'ringside';
     $props['sidenav_url'] = 'ringside';
     $props['isdefault'] = 1;
     $props['canvas_type'] = 1;
     $apiKey = RingsideSocialConfig::$apiKey;
     $secret = RingsideSocialConfig::$secretKey;
     $appId = 100109;
     $name = 'ringside';
     $appService->createApp($name, $apiKey, $secret, $props, $appId);
     $props = array();
     $props['callback_url'] = "{$demoUrl}/fbfootprints/footprints/";
     $props['canvas_url'] = 'footprints';
     $props['sidenav_url'] = 'sideUrl 1';
     $props['isdefault'] = 0;
     $props['canvas_type'] = 1;
     $props['icon_url'] = "{$demoUrl}/images/icon-footprints.png";
     $props['description'] = 'Footprints is a demo application from Facebook.';
     $apiKey = '4333592132647f39255bb066151a2099';
     $secret = 'b37428ff3f4320a7af98b4eb84a4aa99';
     $appId = 100101;
     $name = 'Footprints';
     $appService->createApp($name, $apiKey, $secret, $props, $appId);
     $props = array();
     $props['callback_url'] = "{$demoUrl}/espn/";
     $props['canvas_url'] = 'espn';
     $props['sidenav_url'] = 'sideUrl 1';
     $props['isdefault'] = 0;
     $props['canvas_type'] = 1;
     $props['icon_url'] = "{$webUrl}/images/default-app.png";
     $props['description'] = 'ESPN Headline News';
     $apiKey = 'espnkey';
     $secret = 'espnsecret';
     $appId = 100210;
     $name = 'ESPN Social Network';
     $appService->createApp($name, $apiKey, $secret, $props, $appId);
     $props = array();
     $props['callback_url'] = "http://www.last.fm/opensocial/myfavouritemusic.xml";
     $props['canvas_url'] = 'lastfm';
     $props['isdefault'] = 0;
     $props['desktop'] = 0;
     $props['developer_mode'] = 0;
     $props['mobile'] = 0;
     $props['deployed'] = 0;
     $props['canvas_type'] = 2;
     $props['icon_url'] = "http://cdn.last.fm/matt/nice_favicon.png";
     $props['description'] = 'This application allows you to play at your LastFM channels using an OpenSocial gadget.';
     $props['default_column'] = 1;
     $apiKey = 'f3ba8debc58637bcd2a74e1cfdd8b4f1';
     $secret = '796aa6bc8d81d958847eb38e85761882';
     $appId = 100202;
     $name = 'LastFM';
     $appService->createApp($name, $apiKey, $secret, $props, $appId);
     $props = array();
     $props['callback_url'] = "http://www.sortr.com/social_gadgets/youtube_xml.php";
     $props['canvas_url'] = 'youtube';
     $props['isdefault'] = 0;
     $props['desktop'] = 0;
     $props['developer_mode'] = 0;
     $props['mobile'] = 0;
     $props['deployed'] = 0;
     $props['canvas_type'] = 2;
     $props['icon_url'] = "http://www.youtube.com/favicon.ico";
     $props['description'] = 'Recommend movies to your friends.';
     $props['default_column'] = 1;
     $apiKey = '94f54af54dbcdfa9b1542a2a16bce68e';
     $secret = 'cc223c93558f876eab794e62f9711a36';
     $appId = 100213;
     $name = 'youtube';
     $appService->createApp($name, $apiKey, $secret, $props, $appId);
     $props = array();
     $props['callback_url'] = "{$socialUrl}/trust.php";
     $props['canvas_url'] = '';
     $props['isdefault'] = 0;
     $props['desktop'] = 0;
     $props['developer_mode'] = 0;
     $props['mobile'] = 0;
     $props['deployed'] = 0;
     $props['canvas_type'] = 1;
     $props['icon_url'] = "{$webUrl}/images/default-app.png";
     $props['description'] = 'This application exists only to support the Trail Map 7 widget demo and will not run in a canvas.';
     $props['default_column'] = 1;
     $apiKey = 'cecdc629adb83f81236ba9342ce68492';
     $secret = 'c2161e95173c45b4837ef5b1454fbd65';
     $appId = 100207;
     $name = 'RS Widget Demo';
     $appService->createApp($name, $apiKey, $secret, $props, $appId);
     $props = array();
     $props['callback_url'] = "{$socialUrl}/gadgets/files/tests/compliancetests.xml";
     $props['canvas_url'] = 'compliancetests';
     $props['isdefault'] = 0;
     $props['desktop'] = 0;
     $props['developer_mode'] = 0;
     $props['mobile'] = 0;
     $props['deployed'] = 0;
     $props['canvas_type'] = 2;
     $props['icon_url'] = "{$webUrl}/images/comply.gif";
     $props['description'] = 'OpenSocial 0.7 Compliance Tests. Determines if your OpenSocial container conforms to the OS specification.';
     $props['default_column'] = 1;
     $apiKey = 'd9f41885c9c34bd53364cf1d611efecd';
     $secret = 'f12c83ba65d7f8cb1d11efce1631eaad';
     $appId = 100208;
     $name = 'OS Compliance Tests';
     $appService->createApp($name, $apiKey, $secret, $props, $appId);
     $props = array();
     $props['callback_url'] = "{$socialUrl}/gadgets/files/tests/ringsidetests.xml";
     $props['canvas_url'] = 'ringsidetests';
     $props['isdefault'] = 0;
     $props['desktop'] = 0;
     $props['developer_mode'] = 0;
     $props['mobile'] = 0;
     $props['deployed'] = 0;
     $props['canvas_type'] = 2;
     $props['icon_url'] = "{$webUrl}/images/ringside.gif";
     $props['description'] = 'Runs functional tests on OpenSocial\'s mapping to Ringside data.';
     $props['default_column'] = 1;
     $apiKey = '1882266fc526e79fbd51438f2fb17183';
     $secret = 'ccbfc51f8c517aaa91a2de4917c29713';
     $appId = 100214;
     $name = 'Ringside Tests';
     $appService->createApp($name, $apiKey, $secret, $props, $appId);
 }
Esempio n. 29
0
 /**
  * Creates an instance of the domain service
  *
  * @param string $implClass optional - implementation class name to instantiate.
  * @return Api_Bo_BetterFriendsService
  */
 public static function create($implClass = null)
 {
     return Api_ServiceFactory::create('Api_Bo_BetterFriendsService', self::DEFAULT_DOMAIN_SERVICE, $implClass);
 }
Esempio n. 30
0
 /**
  * Returns an array containing the information on the given application
  * identified by its app ID.
  *
  * @return array list of information on the given application deployed in the server
  */
 public function execute()
 {
     $appService = Api_ServiceFactory::create('AppService');
     $_app = $appService->getApp($this->appId);
     return array('application' => $_app);
 }