本文整理汇总了PHP中Facebook\FacebookSession::enableAppSecretProof方法的典型用法代码示例。如果您正苦于以下问题:PHP FacebookSession::enableAppSecretProof方法的具体用法?PHP FacebookSession::enableAppSecretProof怎么用?PHP FacebookSession::enableAppSecretProof使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Facebook\FacebookSession
的用法示例。
在下文中一共展示了FacebookSession::enableAppSecretProof方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testAppSecretProof
public function testAppSecretProof()
{
FacebookSession::enableAppSecretProof(true);
$request = new FacebookRequest(FacebookTestHelper::$testSession, 'GET', '/me');
$this->assertTrue(isset($request->getParameters()['appsecret_proof']));
FacebookSession::enableAppSecretProof(false);
$request = new FacebookRequest(FacebookTestHelper::$testSession, 'GET', '/me');
$this->assertTrue(!isset($request->getParameters()['appsecret_proof']));
}
示例2: initialize
/**
* Initializes facebook's connection.
*
* @throws FacebookRequestException
* @throws \Exception
*/
private function initialize()
{
FacebookSession::enableAppSecretProof(false);
$session = new FacebookSession($this->accessToken);
try {
$session->validate();
} catch (FacebookRequestException $e) {
$this->entry->addException($e->getMessage());
} catch (\Exception $e) {
$this->entry->addException($e->getMessage());
}
$this->session = $session;
}
示例3: __construct
/**
* @param FacebookSession $session A Facebook API session
* @param LoggerInterface $logger A PSR-3 compatible logger
*/
public function __construct(FacebookSession $session, LoggerInterface $logger = null)
{
$this->session = $session;
$this->logger = $logger ?: new NullLogger();
if (static::instance() === null) {
static::setInstance($this);
}
try {
FacebookSession::_getTargetAppSecret();
} catch (FacebookSDKException $f) {
// Disable sending app secret proof and warn
FacebookSession::enableAppSecretProof(false);
trigger_error('You should set a default app id and secret, see the README.md file ' . 'for more information.', E_USER_DEPRECATED);
}
}
示例4: grabSocial
/**
* Grab the user's ungrabbed posts from Facebook
*
* @param \yii\authclient\BaseOAuth $client
*/
public static function grabSocial(\yii\authclient\BaseOAuth $client)
{
if ($client->getId() === 'facebook') {
$token = $client->getAccessToken();
\Facebook\FacebookSession::enableAppSecretProof(false);
$session = new \Facebook\FacebookSession($token->getToken());
$request = new \Facebook\FacebookRequest($session, 'GET', "/me/posts");
$response = $request->execute()->getResponse();
$posts = $response->data;
foreach ($posts as $post) {
if (!Fbposts::find()->where('post_id = :pid', ['pid' => $post->id])->exists()) {
$fbpost = new Fbposts(['user_id' => Yii::$app->user->id, 'post_id' => $post->id, 'message' => isset($post->message) ? $post->message : $post->story, 'created_time' => $post->created_time]);
$fbpost->save();
}
}
}
}
示例5: addAction
/**
* Create a new user
*
* @param Request $request
* @return Response
* @throws FacebookRequestException
*/
public function addAction(Request $request)
{
$data = $request->json()->get('User');
if (!$data) {
return showErrorResponse('Incorrect request parameters', HTTP_UNPROCESSABLE_ENTITY);
}
try {
$new_user = new Users();
$new_user->addUser($data);
} catch (\Exception $e) {
return showErrorResponse($e->getMessage());
}
//Send push notifications to all Facebook friends who are using Masarap
$fb_access_token = $data[CONSTANTS::KEY_FB_ACCESS_TOKEN];
if (!$fb_access_token) {
return showErrorResponse('Failed to access Facebook account');
}
FacebookSession::setDefaultApplication(Config::get('services.facebook.client_id'), Config::get('services.facebook.client_secret'));
FacebookSession::enableAppSecretProof(false);
$facebook_session = new FacebookSession($fb_access_token);
$facebook_response = (new FacebookRequest($facebook_session, 'GET', '/me/friends/'))->execute();
$friend_list = $facebook_response->getResponse();
$failed_notifications = array();
foreach ($friend_list->data as $friend) {
$friend_user = Users::getByFbId($friend->id);
if (!$friend_user) {
continue;
}
$params = array(CONSTANTS::KEY_USER_ID_FROM => $new_user->id, CONSTANTS::KEY_USER_ID_TO => $friend_user->id, CONSTANTS::KEY_TYPE => CONSTANTS::NOTIFICATION_TYPE_FRIEND_JOIN, CONSTANTS::KEY_TYPE_ID => $new_user->id);
try {
$notification = new Notification();
$notification->addGeneralNotification($params);
} catch (\Exception $e) {
$failed_notifications[] = $friend_user->id;
}
}
$json_return[KeyParser::data] = array(KeyParser::user => ModelFormatter::userLongFormat($new_user), KeyParser::message => 'User successfully registered and push notifications are sent to Facebook friends', KeyParser::unsent_notifications => $failed_notifications);
return response()->json($json_return);
}
示例6: examin_degree_group
public function examin_degree_group($cid)
{
set_time_limit(0);
$this->readBadWords();
$group = DegreeGroup::model()->findByPk($cid);
/*if(!isset($group)){
$group = new DegreeGroup();
$group->cid = $_POST['DegreeGroup']['cid'];
$group->degree_id = $_POST['DegreeGroup']['degree_id'];
}*/
// $degree_group = DegreeGroup::model()->findByAttributes(array('degree_id' => $group->degree_id));
if (isset($group->cid)) {
FacebookSession::enableAppSecretProof(false);
FacebookSession::setDefaultApplication('286043231591201', '4efa214db52acdafb2757124e0d55d9d');
$extended_token = FbToken::model()->findByPk(1);
$session = new FacebookSession($extended_token->token);
$extract_group_info = (new FacebookRequest($session, 'GET', '/' . $group->cid))->execute()->getGraphObject(GraphUser::className());
$this->saveDegreeGroupInfo($extract_group_info, $group->degree_id);
$limit = 25;
$offset = 0;
$extract_group_members = (new FacebookRequest($session, 'GET', '/' . $group->cid . '/members?limit=' . $limit . '&offset=' . $offset))->execute()->getGraphObject(GraphUser::className());
while ($extract_group_members->getProperty('data')->getProperty(0) != null) {
$this->saveGroupMember($extract_group_members->getProperty('data'), $group->cid, 'Degree');
$next = '';
if ($extract_group_members->getProperty('paging') != null && $extract_group_members->getProperty('paging')->getProperty('next') != null) {
$next = $extract_group_members->getProperty('paging')->getProperty('next');
$next = str_replace('https://graph.facebook.com/v2.0/', '', $next);
$next = str_replace('https://graph.facebook.com/v2.1/', '', $next);
$extract_group_members = (new FacebookRequest($session, 'GET', '/' . $next))->execute()->getGraphObject(GraphUser::className());
} else {
$extract_group_members = null;
}
// $offset = $offset + $limit;
// $extract_group_members = (new FacebookRequest(
// $session, 'GET', '/'.$group->cid.'/members?limit='.$limit.'&offset='.$offset
// ))->execute()->getGraphObject(GraphUser::className());
}
$limit = 25;
$offset = 0;
if (isset($group->update_time)) {
$since = "since=" . $group->update_time;
} else {
$since = "since=5+years+ago";
}
$until = date("Y-m-d") . " " . date("H:i:s");
$until = DateTime::createFromFormat('Y-m-d H:i:s', $until);
$until->sub(new DateInterval('P3D'));
$o = new ReflectionObject($until);
$p = $o->getProperty('date');
$until = $p->getValue($until);
$extract_group_feed = array();
try {
$extract_group_feed = (new FacebookRequest($session, 'GET', '/' . $group->cid . '/feed?limit=10000&' . $since . '&until=' . $until))->execute()->getGraphObject(GraphUser::className());
} catch (Exception $e) {
try {
$extract_group_feed = (new FacebookRequest($session, 'GET', '/' . $group->cid . '/feed?limit=1000&' . $since . '&until=' . $until))->execute()->getGraphObject(GraphUser::className());
} catch (Exception $e) {
try {
$extract_group_feed = (new FacebookRequest($session, 'GET', '/' . $group->cid . '/feed?limit=500&' . $since . '&until=' . $until))->execute()->getGraphObject(GraphUser::className());
} catch (Exception $e) {
echo " eccezione ";
}
}
}
$result = '';
while ($extract_group_feed->getProperty('data') != null) {
$j = 0;
$extract_group_feed_data = ' ';
$post_to_save = array('data' => array());
$limit_cicle = 0;
$extract_group_feed_data = $extract_group_feed->getProperty('data')->getProperty(0);
while ($extract_group_feed_data != null) {
// $result = $this->verifyText($extract_group_feed_data, $group->degree_id);
if ($result == '') {
$this->saveGroupFeed($extract_group_feed, $group->cid, 'Degree', $session, $limit_cicle);
} else {
$course = Courses::model()->findByAttributes(array('name' => $result, 'degree_id' => $group->degree_id));
$exam_group = '';
if ($course != null) {
$exam_group = ExamGroup::model()->findByAttributes(array('courses_id' => $course->cid));
}
if ($course != null) {
if ($exam_group == null) {
$exam_group = new ExamGroup();
$criteria = new CDbCriteria();
$criteria->select = 'MIN(eid) AS min';
$row = $exam_group->model()->find($criteria);
$min_id = $row['min'];
$exam_group->eid = $min_id - 1;
}
$exam_group->degree_id = $group->degree_id;
$exam_group->degree_group_id = $group->cid;
$exam_group->courses_id = $course->cid;
$exam_group->name = $course->name;
$exam_group->validate();
$exam_group->save();
$this->saveGroupFeed($extract_group_feed, $exam_group->eid, 'Exam', $session, $limit_cicle);
} else {
$this->saveGroupFeed($extract_group_feed, $group->cid, 'Degree', $session, $limit_cicle);
}
//.........这里部分代码省略.........
示例7: array
static function create_facebook_account($redirect_url)
{
$response = array('status' => false);
$config = get_config('facebook');
$helper = new FacebookRedirectLoginHelper(base_url('login/facebook'), $config['app_id'], $config['app_secret']);
FacebookSession::enableAppSecretProof(false);
$session = $helper->getSessionFromRedirect();
$userdata = $_SESSION['check_login'];
if (isset($session) && $userdata) {
// get long term token
$accessToken = $session->getAccessToken();
$facebook_user_token = $accessToken->extend($config['app_id'], $config['app_secret']);
// graph api request for user data
$request = new FacebookRequest($session, 'GET', '/me?fields=first_name,last_name,email');
$response = $request->execute();
// get response
$graphObject = $response->getGraphObject();
$user = Users_Model::find_by_email($graphObject->getProperty('email'));
if (sizeof($user) <= 0) {
$user = new Users_Model();
}
$user->first_name = $graphObject->getProperty('first_name');
$user->last_name = $graphObject->getProperty('last_name');
$user->email = $graphObject->getProperty('email');
$user->type = self::USER_TYPE_FACEBOOK;
$user->registration_date = date("Y-m-d H:i:s");
$user->save();
/**
* Update social meta key
*/
$UserMeta = Usermetum::find_by_user_id_and_meta_key_and_meta_value($user->user_id, 'social_type', 'facebook');
if (sizeof($UserMeta) <= 0) {
$UserMeta = new Usermetum();
}
$UserMeta->user_id = $user->user_id;
$UserMeta->meta_key = 'social_type';
$UserMeta->meta_value = 'facebook';
$UserMeta->save();
/**
* Save user long token
*/
$UserMeta = Usermetum::find_by_user_id_and_meta_key_and_meta_value($user->user_id, 'social_type', 'facebook');
if (sizeof($UserMeta) <= 0) {
$UserMeta = new Usermetum();
}
$UserMeta->user_id = $user->user_id;
$UserMeta->meta_key = 'facebook_user_token';
$UserMeta->meta_value = $facebook_user_token;
$UserMeta->save();
/**
* Update social meta value
*/
$UserMeta = Usermetum::find_by_user_id_and_meta_key_and_meta_value($user->user_id, 'social_id', $graphObject->getProperty('id'));
if (sizeof($UserMeta) <= 0) {
$UserMeta = new Usermetum();
}
$UserMeta->user_id = $user->user_id;
$UserMeta->meta_key = 'social_id';
$UserMeta->meta_value = $graphObject->getProperty('id');
$UserMeta->save();
// see if we have a session
$_SESSION['login'] = array('user_id' => $user->user_id, 'email' => $graphObject->getProperty('email'), 'user_level' => 1, 'first_name' => $graphObject->getProperty('first_name'), 'last_name' => $graphObject->getProperty('last_name'));
$response = array('status' => 'redirect', 'url' => base_url("Dashboard"));
} else {
$permissions = array('publish_actions', 'email', 'user_location', 'user_birthday', 'user_likes', 'public_profile', 'user_friends');
$_SESSION['check_login'] = true;
$loginUrl = $helper->getLoginUrl($permissions);
$response = array('status' => 'redirect', 'url' => $loginUrl);
}
return $response;
}
示例8: api
public function api($params, $path, $id = false, $session = false)
{
if (!$this->session && ${${"GLOBALS"}["aksbebw"]}) {
FacebookSession::enableAppSecretProof(false);
$this->session = FacebookSession::newAppSession();
}
if ($this->session) {
try {
$tcfjgobu = "params";
$skkiybshouo = "objects";
${"GLOBALS"}["bpcqqafmbh"] = "objects";
${"GLOBALS"}["idogdltxft"] = "path";
${${"GLOBALS"}["rvfbvujkf"]} = (new FacebookRequest($this->session, ${${"GLOBALS"}["idogdltxft"]}, ${$tcfjgobu}, ${${"GLOBALS"}["bwisnqcgi"]}))->execute();
${${"GLOBALS"}["bpcqqafmbh"]} = $request->getGraphObject()->asArray();
return ${$skkiybshouo};
} catch (FacebookSDKException $e) {
return array("error" => $e->getMessage());
} catch (FacebookRequestException $e) {
return array("error" => $e->getMessage());
} catch (FacebookAuthorizationException $e) {
return array("error" => $e->getMessage());
}
}
}
示例9: __construct
public function __construct()
{
FacebookSession::setDefaultApplication(Config::get('social.facebook.app_id'), Config::get('social.facebook.app_secret'));
FacebookSession::enableAppSecretProof(Config::get('social.facebook.app_secret_proof'));
}
示例10: followFBUsersAction
/**
* Returns a list of Facebook friends who are using Masarap which you have not yet followed
*
* @param Request $request
* @return Response
* @throws FacebookRequestException
*/
public function followFBUsersAction(Request $request)
{
$json_return[KeyParser::data] = array(KeyParser::users => array());
$data = $request->json()->get('User');
if (!$data) {
return showErrorResponse('Incorrect request parameters', HTTP_UNPROCESSABLE_ENTITY);
}
$user_id = $data[CONSTANTS::KEY_ID];
$fb_access_token = $data[CONSTANTS::KEY_FB_ACCESS_TOKEN];
if (!$fb_access_token) {
return showErrorResponse('Failed to access Facebook account');
}
FacebookSession::setDefaultApplication(Config::get('services.facebook.client_id'), Config::get('services.facebook.client_secret'));
FacebookSession::enableAppSecretProof(false);
$facebook_session = new FacebookSession($fb_access_token);
$facebook_response = (new FacebookRequest($facebook_session, 'GET', '/me/friends?limit=5000'))->execute();
$friend_list = $facebook_response->getResponse();
$facebook_friends = array();
$followed_users = array();
$friend_count = 0;
foreach ($friend_list->data as $friend) {
$friend_user = Users::getByFbId($friend->id);
if (!$friend_user) {
continue;
}
$is_followed = Follow::isFollowed($user_id, $friend_user->id);
$follower_count = Follow::getCountByUserId($friend_user->id, CONSTANTS::FOLLOW_FOLLOWER);
$review_count = Reviews::getCountByUserId($friend_user->id);
if (!$is_followed && $friend_user->id != $user_id) {
$facebook_friends[$friend_count] = ModelFormatter::userFormat($friend_user);
$facebook_friends[$friend_count] += array(KeyParser::follower_count => $follower_count, KeyParser::review_count => $review_count, KeyParser::is_followed_by_viewer => $is_followed);
} elseif ($is_followed && $friend_user->id != $user_id) {
$followed_users[$friend_count] = ModelFormatter::userFormat($friend_user);
$followed_users[$friend_count] += array(KeyParser::follower_count => $follower_count, KeyParser::review_count => $review_count, KeyParser::is_followed_by_viewer => $is_followed);
}
$friend_count++;
}
$facebook_friends = array_merge($facebook_friends, $followed_users);
$json_return[KeyParser::data][KeyParser::users] = $facebook_friends;
return response()->json($json_return);
}