public function executeFacebookadd($request) { $username = $request->getParameter('username'); if ($username == '') { return sfView::ERROR; } $fbUserJSON = @file_get_contents('http://graph.facebook.com/' . $username); if (!$fbUserJSON) { return sfView::ERROR; } $fbUser = json_decode($fbUserJSON, true); if (!is_array($fbUser) || !isset($fbUser['id'])) { return sfView::ERROR; } /* @var $user User */ $user = $this->getUser()->getRaykuUser(); $userFb = $user->getUserFb(); if (!$userFb) { $userFb = new UserFb(); $userFb->setUser($user); } $userFb->setFbUsername($username); $userFb->setFbUid($fbUser['id']); $userFb->save(); $this->weAreFriendsNow = $request->getGetParameter('action'); if ($this->weAreFriendsNow) { /** * @todo - accept new friend on RaykuBot FB profile */ BotServiceProvider::createFor(sfConfig::get('app_facebook_url') . "/queue_friendship_worker")->getContent(); } }
/** * Sets a single UserFb object as related to this object by a one-to-one relationship. * * @param UserFb $l UserFb * @return User The current object (for fluent API support) * @throws PropelException */ public function setUserFb(UserFb $v) { $this->singleUserFb = $v; // Make sure that that the passed-in UserFb isn't already associated with this object if ($v->getUser() === null) { $v->setUser($this); } return $this; }