return isset($cache[$cache_key]) ? $cache[$cache_key] : NULL;
}
-
-function fb_access_token($fb = NULL) { // deprecated XXX use fb_get_token()
- dpm(debug_backtrace(), "deprecated function called.");
- static $cache;
- if (!isset($fb))
- $fb = $GLOBALS['_fb'];
- if (!$fb)
- return;
-
- $apikey = $fb->getAppId();
-
- if (!isset($cache))
- $cache = array();
-
- if (!isset($cache[$apikey])) {
- $path = "https://graph.facebook.com/oauth/access_token?client_id=" . $fb->getAppId() . "&client_secret=" . $fb->getApiSecret() . "&type=client_cred";
- $http = drupal_http_request($path);
- if (isset($http->data)) {
- $data = explode('=', $http->data);
- $token = $data[1];
- if ($token)
- $cache[$apikey] = $token;
- }
- }
- if (isset($cache[$apikey])) {
- return $cache[$apikey];
- }
-}
-
-function fb_access_token_user($fbu = NULL, $fb = NULL) { // deprecated XXX use fb_get_token()
- dpm(debug_backtrace(), "deprecated function called.");
- static $cache;
- if (!isset($fb))
- $fb = $GLOBALS['_fb'];
- if (!isset($fbu) || $fbu == 'me' || $fbu == fb_facebook_user($fb)) {
- $session = $fb->getSession();
- $token = $session['access_token'];
- }
- else {
- // @TODO look up another user's access token.
- }
- return $token;
-}
-
-
/**
- * Facebook's own php-sdk is so friggin' buggy. If you try $_fb->api(...) and
- * get invalid parameters exceptions, this may work instead.
+ * This helper original written because facebook's $fb->api() function was
+ * very buggy. I'm not sure this is still needed. On the other hand, a
+ * future version of modules/fb might use this instead of faceobok's PHP SDK,
+ * eliminating the need for it entirely.
*/
function fb_call_method($fb, $method, $params = array()) {
$params['access_token'] = fb_get_token($fb);
return $form;
}
-/**
- * Helper function to produce a request or invite form. Note that this does
- * not produce a full form (i.e. never use
- * drupal_get_form('fb_form_request_form')). The caller is expected to fill
- * out the rest of the form before returning it for use with drupal_get_form.
- *
- * DEPRECATED
- */
-function fb_form_request_formXXX($config = array()) {
- global $_fb, $_fb_app; // only works on canvas pages.
-
- // Default config
- $config = array_merge(array('type' => $_fb_app->label,
- 'content' => 'INVITE CONTENT XXX',
- 'action' => 'http://apps.facebook.com/' . $_fb_app->canvas,
- 'invite' => 'true',
- 'method' => 'POST',
- ), $config);
-
- // form type fb:request-form
- $form = array('#fb_form_type_hack' => 'fb_form_request', /* becomes #type during form_alter */
- '#attributes' => array('type' => $config['type'],
- 'content' => htmlentities($config['content']),
- 'invite' => $config['invite'],
- ),
- '#action' => $config['action'],
- );
-
- // Caller must add fb:multi-friend-selector or some other selector.
-
- return $form;
-}
-
-
-/**
- * Based on theme_form, this renders an fb:request-form.
- */
-function theme_fb_form_requestXXX($element) {
- // TODO: verify attributes required by facebook are found.
-
- // Anonymous div to satisfy XHTML compliance.
- $action = $element['#action'] ? 'action="' . check_url($element['#action']) . '" ' : '';
- $output = '<fb:request-form '. $action .' method="'. $element['#method'] .'" '. 'id="'. $element['#id'] .'"'. drupal_attributes($element['#attributes']) .">\n<div>". $element['#children'] ."\n</div></fb:request-form>\n";
-
- return $output;
-}
// Because the fb:request-form includes its own buttons, including the particularly annoying skip button, this submit callback is not used. Will probably delete it. If I can't make it work properly.
function fb_form_multi_add_invite_form_submit() {