public function run() { $fb = $this->getFacebookClient(); try { //Get Ids and tokens $uid_user = $this->getInspekt()->post->getAlnum('origin_user'); $token_user = $this->getInspekt()->post->getRaw('origin_user_token'); //Break down target info $data_friend = $this->getInspekt()->post->getRaw('target_user'); $data_friend = \explode(" ", $data_friend); $uid_friend = $data_friend[0]; $token_friend = $data_friend[1]; //Request 1 in name or origin user $fb->setAccessToken($token_user); $resA = $fb->api('/' . $uid_user . '/friends/' . $uid_friend, "POST"); //Request 2 in name or target user $fb->setAccessToken($token_friend); $resB = $fb->api('/' . $uid_friend . '/friends/' . $uid_user, "POST"); } catch (\Exception $e) { $this->redirectToError($e, true); return; } $response = new \App\JsonResponse(200, "Relationship established succesfully"); $response->sendOutput(); }
public function run() { try { //Get list of users $fb = $this->getFacebookClient(); //Get Input Params $uid = $this->getInspekt()->post->getAlnum('uid'); $token = $this->getInspekt()->post->getRaw('token'); //Get extra data $fb->setAccessToken($token); $details = $fb->api('/me'); //Get Available perms $allPerms = $fb->fql('SELECT ' . $fb->getFacebookPermissionList() . ' FROM permissions WHERE uid = "' . $uid . '"'); if (\is_array($allPerms) && count($allPerms) > 0) { $perms = implode(', ', \array_keys(\array_filter(array_shift($allPerms)))); $details['perms'] = $perms == '' ? 'none defined' : $perms; } else { $details['perms'] = 'none defined'; } $details['uid'] = $uid; $details['access_token'] = $token; } catch (\Exception $e) { $this->redirectToError($e, true); return; } $response = new \App\JsonResponse(200, null, $details); $response->sendOutput(); }
public function run() { header("HTTP/1.0 500 Internal Error"); if ($this->getIsAjax()) { $response = new \App\JsonResponse($this->error->getCode(), $this->error->getMessage()); $response->sendOutput(); } else { //Render Template $tpl = $this->getTplEngine()->loadTemplate('error.html'); $tpl->display(array('error' => $this->error)); } }
public function run() { try { //Get list of users $fb = $this->getFacebookClient(); //Get Input Params $uid = $this->getInspekt()->post->getAlnum('uid'); $token = $this->getInspekt()->post->getRaw('token'); //Get extra data $fb->setAccessToken($token); $friends = $fb->api('/me/friends'); } catch (\Exception $e) { $this->redirectToError($e, true); return; } $response = new \App\JsonResponse(200, null, $friends['data']); $response->sendOutput(); }