本文整理汇总了PHP中Facebook::UpdateAccessToken方法的典型用法代码示例。如果您正苦于以下问题:PHP Facebook::UpdateAccessToken方法的具体用法?PHP Facebook::UpdateAccessToken怎么用?PHP Facebook::UpdateAccessToken使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Facebook
的用法示例。
在下文中一共展示了Facebook::UpdateAccessToken方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: trim
<div class='alerts'></div>
<?php
if (isset($_POST['submit'])) {
$accessToken = trim($_POST['accessToken']);
if (empty($accessToken)) {
echo "<script> alertBox('" . lang('ENTER_ACCESS_TOKEN') . "','danger');</script>";
} else {
$user = new User();
$fb = new Facebook();
$fb_account = new FbAccount();
$app_id = "145634995501895";
try {
if ($fb_account->UserDefaultFbAccount()) {
if ($fb->IsATValid($accessToken)) {
if ($fb->GetAccessToken($app_id)) {
$fb->UpdateAccessToken($user->data()->id, $app_id, $fb_account->UserDefaultFbAccount(), $accessToken);
} else {
$fb->SaveAccessToken($user->data()->id, $app_id, $fb_account->UserDefaultFbAccount(), $accessToken);
}
echo "<script>window.opener.location.href;window.close();</script>";
} else {
throw new Exception(lang('INVALID_ACCESS_TOKEN'));
}
} else {
throw new Exception(lang('NO_FB_ACCOUNT_SELECTED'));
}
} catch (Exception $e) {
echo "<script> alertBox('" . $e->getMessage() . "','danger');</script>";
}
}
}
示例2: lang
// get facebook User info
$userData = $fb->GetUserFromAccessToken(Input::Get("fb_accesstoken"));
if ($userData == null) {
echo lang("UNABLE_TO_GET_FB_ACCOUNT_DETAILS");
exit;
}
// Get user groups
$fbgroups = $fb->LoadFbGroups(Input::Get("fb_accesstoken"));
if (!$fbgroups) {
echo lang("UNABLE_GET_FB_GROUPS");
exit;
}
// Save access token
if ($fbAppDetails = $fb->AppDetailsFromAt(Input::Get("fb_accesstoken"))) {
if ($fb->GetAccessToken($fbAppDetails->id, $userData->id)) {
$fb->UpdateAccessToken($user->data()->id, $fbAppDetails->id, $userData->id, Input::Get("fb_accesstoken"));
} else {
$fb->SaveAccessToken($user->data()->id, $fbAppDetails->id, $userData->id, Input::Get("fb_accesstoken"));
}
} else {
echo lang("UNABLE_TO_GET_FB_APP_DETAILS");
exit;
}
// Save new facebook account
$fbaccount->setUserId($user->data()->id);
$fbaccount->setFbId($userData->id);
$fbaccount->setLastname($userData->first_name);
$fbaccount->setFirstname($userData->last_name);
$fbaccount->setGroups($fbgroups);
if (!$fbaccount->UserFbAccountDefaultApp()) {
$fbaccount->setDefaultApp($fbAppDetails->id);