本文整理汇总了PHP中Facebook::getAppId方法的典型用法代码示例。如果您正苦于以下问题:PHP Facebook::getAppId方法的具体用法?PHP Facebook::getAppId怎么用?PHP Facebook::getAppId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Facebook
的用法示例。
在下文中一共展示了Facebook::getAppId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isLoginRequest
/**
*
* Tells if the current page load appears to be the result of
* an attempt to log in.
*
* @return bool
*
*/
public function isLoginRequest()
{
// check for a facebook session
if ($this->_request->cookie('fbs_' . $this->_facebook->getAppId())) {
return true;
}
}
示例2: facebook_init
function facebook_init()
{
require 'src/facebook.php';
global $facebook;
$facebook = new Facebook(array('appId' => FB_KEY, 'secret' => FB_SECRET));
if (!empty($_SESSION) && !empty($_SESSION['fb_code'])) {
$url = "https://graph.facebook.com/oauth/access_token?";
$params = array();
$params[] = 'client_id=' . $facebook->getAppId();
$params[] = 'redirect_uri=' . 'http://' . HOST . get_url('/facebook/auth/');
$params[] = 'client_secret=' . $facebook->getApiSecret();
$params[] = 'code=' . $_SESSION['fb_code'];
$url .= implode('&', $params);
$data = explode('&', get_data($url));
foreach ($data as &$d) {
$d = explode('=', $d);
if ($d[0] == 'access_token') {
$_SESSION['fb_access_token'] = $d[1];
} elseif ($d[0] == 'expires') {
$_SESSION['fb_at_expires'] = time() + $d[1];
}
}
}
if (array_key_exists('fb_access_token', $_SESSION)) {
if ($_SESSION['fb_at_expires'] > time()) {
$facebook->setAccessToken($_SESSION['fb_access_token']);
unset($_SESSION['fb_code']);
}
}
}
示例3: _postConstruct
/**
*
* Generates the script block required by Facebook.
*
* @return void
*
*/
protected function _postConstruct()
{
parent::_postConstruct();
// retain the facebook dependency
$this->_facebook = Solar::dependency('Facebook', $this->_config['facebook']);
// add the FB script to the foot helper
$href = "http://connect.facebook.net/en_US/all.js";
$this->_view->foot()->addScript($href);
// initialize the application and set up login event subscription,
// also done via the foot helper
$appid = $this->_facebook->getAppId();
$inline = <<<INLINE
FB.init({appId: '{$appid}', xfbml: true, cookie: true});
FB.Event.subscribe('auth.login', function(response) {
window.location.reload();
});
INLINE;
$this->_view->foot()->addScriptInline($inline);
}
示例4: isLogoutRequest
/**
*
* Tells if the current page load appears to be the result of
* an attempt to log out, if so resets the facebook cookie
*
* @return bool
*
*/
public function isLogoutRequest()
{
if ($this->_request->isCsrf()) {
return false;
}
$method = $this->_config['method'];
if ($this->_request->{$method}($this->_config['source_process']) == $this->_config['process']) {
setcookie('fbs_' . $this->_facebook->getAppId(), "", time() - 36000);
return true;
}
return false;
}
示例5: getAccess
public function getAccess($token, $secret, $verifier)
{
$code = JRequest::getVar('code');
$params = array('client_id' => parent::getAppId(), 'redirect_uri' => $this->callback, 'client_secret' => parent::getApiSecret(), 'code' => $code);
$token = parent::_oauthRequest(parent::getUrl('graph', '/oauth/access_token'), $params);
$token = str_ireplace('access_token=', '', $token);
$obj = new stdClass();
$obj->token = $token;
$obj->secret = 'facebook';
$obj->params = '';
return $obj;
}
示例6: Users_before_Q_objects
function Users_before_Q_objects()
{
$app = Q_Config::expect('Q', 'app');
$fb_info = Q_Config::get('Users', 'facebookApps', $app, null);
// We sometimes pass this in the request, for browsers like Safari
// that don't allow setting of cookies using javascript inside 3rd party iframes
if (!empty($fb_info['appId']) and !empty($_REQUEST['Users']['facebook_authResponse'])) {
$appId = $fb_info['appId'];
$auth_response = $_REQUEST['Users']['facebook_authResponse'];
if (is_array($auth_response)) {
if ($auth_response) {
$cookie = $auth_response['signedRequest'];
$expires = 0;
} else {
$cookie = "";
$expires = 1;
}
try {
$facebook = new Facebook(array('appId' => $fb_info['appId'], 'secret' => $fb_info['secret'], 'fileUpload' => true));
$cookie_name = 'fbsr_' . $facebook->getAppId();
if (!empty($_SERVER['HTTP_HOST'])) {
Q_Response::setCookie($cookie_name, $cookie, $expires);
}
} catch (Exception $e) {
// do nothing
}
}
}
$uri = Q_Dispatcher::uri();
$actions = array('activate' => true);
if ($uri->module === 'Users' and isset($actions[$uri->action])) {
Q::event("Users/{$uri->action}/objects");
}
// Fire an event for hooking into, if necessary
Q::event('Users/objects', array(), 'after');
}
示例7: getAppId
/**
* Returns the app id
*
* @return string
*/
public function getAppId()
{
return $this->facebook->getAppId();
}
示例8: testSetAppId
public function testSetAppId()
{
$facebook = new Facebook(array('appId' => self::APP_ID, 'secret' => self::SECRET));
$facebook->setAppId('dummy');
$this->assertEquals($facebook->getAppId(), 'dummy', 'Expect the App ID to be dummy.');
}
示例9: Facebook
<?php
require 'php-sdk/facebook.php';
$facebook = new Facebook(array('appId' => '124593811064320', 'secret' => '21edb9fabde67d1f0718e13ddcc2ac4f'));
setcookie('fbs_' . $facebook->getAppId(), ' ', time() - 100, '/', 'atetnowski.com/facebook');
$facebook->destroySession();
header('Location: index.php');
示例10: array
<?php
/**
/* This code verifies that the authorization succeded.
**/
//Include libraries
require '../facebook.php';
require '../appengine_functions.php';
//Initialize Facebook's PHP library
$config = array('appId' => '140229329376512', 'secret' => '198fb6f72dfb3a029d410d98e3beb203', 'cookie' => true, 'domain' => true);
$facebook_client = new Facebook($config);
//Initialize variables
$app_id = $facebook_client->getAppId();
$app_secret = $facebook_client->getApiSecret();
$CANVAS_URL = 'http://apps.facebook.com/russ_myfirstapp/';
//Get the access token from Facebook by supplying the App ID & Secret.
$params = array('client_id' => $app_id, 'type' => 'client_cred', 'client_secret' => $app_secret);
$url = "https://graph.facebook.com/oauth/access_token";
$access_token = make_request($url, $params);
// creates a POST request with $params as the parameters.
$access_token = substr($access_token, strpos($access_token, "=") + 1, strlen($access_token));
//If the access token is not present, something went wrong
//so display an error, else, redirect to canvas page.
if ($access_token) {
header('Location: ' . $CANVAS_URL);
} else {
echo 'An error occurred';
}
exit;
示例11: Facebook
if (SpoonSession::exists('public_uid')) {
// Create our Application instance (replace this with your appId and secret).
$facebook = new Facebook(array('appId' => '118234134911012', 'secret' => 'a83b1fbf766dcf41a8238a13f53690bd', 'cookie' => true));
//$facebook->setSession(null);
$session = $facebook->getSession();
//spoon::dump($session);
// Session based API call.
if ($session) {
try {
$db = new SpoonDatabase('mysql', 'localhost', 'xqdchsmn_public', 'pRAcHU8Ajath7qa3', 'xqdchsmn_public');
$record = array();
//$record['fb_access_token'] = $facebook->getAccessToken();
$record['fb_uid'] = $facebook->getUser();
$record['fb_publish_stream'] = true;
$uid = SpoonSession::get('public_uid');
$rows = $db->update('users', $record, 'user_id = ?', $uid);
SpoonHTTP::redirect('dashboardSettings.php');
} catch (FacebookApiException $e) {
error_log($e);
}
} else {
$tpl->assign('fbcbutton', '<fb:login-button perms="email,publish_stream"></fb:login-button>');
//http://developers.facebook.com/docs/authentication/permissions
}
// facebook javascript
$tpl->assign('appid', $facebook->getAppId());
} else {
SpoonHTTP::redirect('login.php');
}
// show the output
$tpl->display('templates/facebookconnect.tpl');
示例12: Facebook
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
require 'src/facebook.php';
Facebook::$CURL_OPTS[CURLOPT_SSL_VERIFYPEER] = false;
Facebook::$CURL_OPTS[CURLOPT_SSL_VERIFYHOST] = 2;
// Create our Application instance (replace this with your appId and secret).
$facebook = new Facebook(array('appId' => 'youkey', 'secret' => 'yoursecret'));
if (isset($_GET['logout'])) {
setcookie('fbs_' . $facebook->getAppId(), '', time() - 100, '/', 'domain.com');
session_destroy();
header('Location:' . $_SERVER['HTTP_REFERER']);
exit;
}
// Get User ID
$user = $facebook->getUser();
// We may or may not have this data based on whether the user is logged in.
//
// If we have a $user id here, it means we know the user is logged into
// Facebook, but we don't know if the access token is valid. An access
// token is invalid if the user logged out of Facebook.
if ($user) {
try {
// Proceed knowing you have a logged in user who's authenticated.
$user_profile = $facebook->api('/me');
示例13: function
print_r($bindings);
print_r($time);
print_r($name);
});
*/
$app->hook("slim.before", function () use($facebook) {
/* IE has problems with crossdomain cookies. */
header('P3P: CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"');
/* When using FB.ui("oauth", ...) */
/* Apparently FB.login() is now inline so this is not necessary */
/* anymore http://goo.gl/22sfO */
if (isset($_REQUEST["session"])) {
$session_data = json_decode($_REQUEST["session"], true);
$url = "https://graph.facebook.com/oauth/exchange_sessions";
$curl = curl_init($url);
$post = array("client_id" => $facebook->getAppId(), "client_secret" => $facebook->getApiSecret(), "sessions" => $session_data["session_key"]);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $post);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($curl);
curl_close($curl);
$exchange_data = json_decode($response, true);
$access_token = $exchange_data[0]["access_token"];
/* Save access toke to session since not all */
/* requests come from Facebook iframe. */
$_SESSION["access_token"] = $access_token;
}
/* When using FB.login(...) or already installed. */
if (isset($_REQUEST["signed_request"])) {
$signed_request = $facebook->getSignedRequest();
if (isset($signed_request["oauth_token"])) {
示例14: getSimpleAppToken
/**
* Generates a simple app access token
*
* @link https://developers.facebook.com/docs/facebook-login/access-tokens/#apptokens
*
* @param \Facebook $facebook
*
* @return string
*/
public function getSimpleAppToken(\Facebook $facebook)
{
return "{$facebook->getAppId()}|{$facebook->getAppSecret()}";
}
示例15: fbButton
public function fbButton()
{
$this->objMods = $this->getObject('modules', 'modulecatalogue');
$this->objDbSysconfig = $this->getObject('dbsysconfig', 'sysconfig');
$show = $this->objDbSysconfig->getValue('show_fbconnect_auth', 'security');
if ($this->objMods->checkIfRegistered('facebookapps') && strtolower($show) == 'true') {
include $this->getResourcePath('facebook.php', 'facebookapps');
$apikey = $this->objDbSysconfig->getValue('apikey', 'facebookapps');
$secret = $this->objDbSysconfig->getValue('apisecret', 'facebookapps');
$appId = $this->objDbSysconfig->getValue('apid', 'facebookapps');
// Create our Application instance (replace this with your appId and secret).
$facebook = new Facebook(array('appId' => $appId, 'secret' => $secret, 'cookie' => true));
$session = $facebook->getSession();
$fbappid = $facebook->getAppId();
$jsess = json_encode($session);
$reloadurl = $this->uri(array('module' => '_default'));
$onloginurl = $this->uri(array('module' => 'security', 'action' => 'fbconnect'));
$fb = '<div id="fb-root"></div>';
$fb .= '<script>
window.fbAsyncInit = function() {
FB.init({
appId : \'' . $fbappid . '\',
session : ' . $jsess . ',
status : true,
cookie : true,
xfbml : true
});
// whenever the user logs in, we refresh the page
FB.Event.subscribe(\'auth.login\', function() {
window.location.(' . $reloadurl . ');
});
};
(function() {
var e = document.createElement(\'script\');
e.src = document.location.protocol + \'//connect.facebook.net/en_US/all.js\';
e.async = true;
document.getElementById(\'fb-root\').appendChild(e);
}());
</script>';
$fb .= '<fb:login-button autologoutlink="false" perms="email,read_stream" onlogin="window.location = \'' . $onloginurl . '\'"></fb:login-button>';
return $fb;
}
}