Index: fb.admin.inc =================================================================== --- fb.admin.inc (revision 5288) +++ fb.admin.inc (working copy) @@ -34,25 +34,24 @@ foreach ($apps as $fb_app) { // Get properties from facebook. - fb_admin_get_app_properties($fb_app); + fb_admin_get_app_info($fb_app); $row = array(); // Title. $row[] = $fb_app->label . ($fb_app->status ? '' : ' ' . t('(not enabled)')); // New apps no longer have about pages. - $name = isset($fb_app->application_name) ? $fb_app->application_name : $fb_app->label; - if ($fb_app->about_url) { - $row[] = l($name, $fb_app->about_url); - } - else { - $row[] = $name; - } + $name = isset($fb_app->name) ? $fb_app->name : $fb_app->label; + $row[] = $name; // Canvas Page. - if (isset($fb_app->canvas_name) && - $fb_app->canvas_name != $fb_app->canvas) { - drupal_set_message(t('Canvas page for %label is out of sync! Facebook believes it is %fbcanvas, while our database believes %canvas. Edit and save the application to remedy this.', array('%label' => $fb_app->label, '%fbcanvas' => $fb_app->canvas_name, '%canvas' => $fb_app->canvas)), 'error'); + if (isset($fb_app->namespace) && + $fb_app->namespace != $fb_app->canvas) { + drupal_set_message(t('Canvas page for %label is out of sync! Facebook believes it is %fbcanvas, while our database believes %canvas. Edit and save the application to remedy this.', array( + '%label' => $fb_app->label, + '%fbcanvas' => $fb_app->namespace, + '%canvas' => $fb_app->canvas, + ), 'error')); } if ($fb_app->canvas) { $row[] = l($fb_app->canvas, $protocol . '://apps.facebook.com/' . $fb_app->canvas); @@ -101,7 +100,7 @@ function fb_admin_app_page($fb_app = NULL) { fb_get_app_data($fb_app); - fb_admin_get_app_properties($fb_app); + fb_admin_get_app_info($fb_app); $fb = fb_api_init($fb_app); // @TODO use an actual theme function and make render more appealing. @@ -110,7 +109,7 @@ unset($fb_app->data); // Warn user if values have changed since last edit. - foreach (array('canvas_name' => 'canvas', 'application_name' => 'title') as $prop => $key) { + foreach (array('namespace' => 'canvas', 'name' => 'title') as $prop => $key) { if (isset($fb_app->$prop) && $fb_app->$prop != $fb_app->$key) { drupal_set_message(t("The property %prop has been changed to %value on facebook. Go to the Edit tab, confirm values are correct and hit Save button to syncronize the local values.", array('%prop' => $prop, '%value' => $fb_app->$prop)), 'error'); @@ -134,10 +133,9 @@ } // This clause belongs in fb_tab.module. But currently no hook for that tab to add a "property" that is not a true facebook property. - // Note: fb_app->installable no longer means anything. - if ($fb_app->profile_tab_url && module_exists('fb_tab')) { + if ($fb_app->page_tab_url && module_exists('fb_tab')) { // This app can be added to a page. Provide a link to do so. - $add_url = "http://www.facebook.com/dialog/pagetab?app_id=$fb_app->id&next=" . url(FB_TAB_PATH_ADDED . '/' . $fb_app->label, array('absolute' => TRUE, 'language' => FALSE)); + $add_url = "http://www.facebook.com/dialog/pagetab?app_id=$fb_app->id&next=" . url(FB_TAB_PATH_ADDED . '/' . $fb_app->label, array('absolute' => TRUE, 'language' => NULL)); $output .= '
' . t('Add to page link') . '
' . l($add_url, $add_url) . '
'; } @@ -154,20 +152,16 @@ return $fb_app->label; } -/** - * Get properties from Facebook. Fills in the data that we need to - * know by querying facebook. - */ -function fb_admin_get_app_properties(&$fb_app) { +function fb_admin_get_app_info(&$fb_app) { static $cache; static $props_map; if (!isset($cache)) { $cache = array(); - // http://wiki.developers.facebook.com/index.php/ApplicationProperties + // https://developers.facebook.com/docs/reference/api/application/ $props_map = array( - t('About URL') => 'about_url', - t('Application Name') => 'application_name', - t('Edit URL') => 'edit_url', + t('Application Name') => 'name', + t('Namespace') => 'namespace', + t('Logo') => 'logo_url', ); $props_map = fb_invoke(FB_ADMIN_OP_LIST_PROPERTIES, array('fb_app' => $fb_app), $props_map, FB_ADMIN_HOOK); } @@ -175,25 +169,28 @@ if (!isset($cache[$fb_app->id])) { if ($fb = fb_api_init($fb_app)) { try { - $props = fb_call_method($fb, 'admin.getAppProperties', array( - 'properties' => implode(',', array_values($props_map)), - )); - $cache[$fb_app->id] = $props; + $info = fb_graph($fb_app->id, array( + 'access_token' => fb_get_token($fb), + 'fields' => implode(',', array_values($props_map)), + )); + dpm($info, __FUNCTION__); + $cache[$fb_app->id] = $info; } catch (Exception $e) { fb_log_exception($e, t('Failed to get application properties (%label) from Facebook', array('%label' => $fb_app->label))); } } } else { - $props = $cache[$fb_app->id]; + $info = $cache[$fb_app->id]; } // Update $fb_app with the values we got from facebook api. foreach ($props_map as $key) { - if (isset($props[$key])) { - $fb_app->$key = $props[$key]; + if (isset($info[$key])) { + $fb_app->$key = $info[$key]; } } + } @@ -260,18 +257,20 @@ } /** - * Button submit function. Use has clicked delete, send them to confirm page. + * Confirm form submit function. + * We don't use fb_app_set_app_properties, because fb_app.module may not be enabled. */ function fb_admin_set_properties_form_submit($form, &$form_state) { $fba_id = $form_state['values']['fba_id']; $fb_app = fb_get_app(array('fba_id' => $fba_id)); + $props = $form['#fb_props']; if ($fb_app && count($props)) { if ($fb = fb_api_init($fb_app)) { try { - $result = fb_call_method($fb, 'admin.setAppProperties', array( - 'properties' => json_encode($props), - )); + $result = fb_graph($fb_app->id, $props + array('access_token' => fb_get_token($fb)), 'POST', $fb); + // @todo handle $result != true, if that ever happens. + // Success. $form_state['redirect'] = FB_PATH_ADMIN_APPS . '/' . $fb_app->label; @@ -287,10 +286,10 @@ // Update local data with values learned from facebook. fb_admin_get_app_properties($fb_app); - if ($fb_app->fba_id && $fb_app->canvas_name && module_exists('fb_app')) { + if ($fb_app->fba_id && $fb_app->namespace && module_exists('fb_app')) { // @TODO - clean this up or move it to fb_app.module. fb.module should have no knowledge of fb_app table. db_query("UPDATE {fb_app} SET canvas='%s' WHERE fba_id = %d", array( - $fb_app->canvas_name, + $fb_app->namespace, $fb_app->fba_id, )); } @@ -320,7 +319,7 @@ '#type' => 'radios', '#title' => t('Use Secure URLs'), '#default_value' => variable_get(FB_VAR_SECURE_URLS, FB_SECURE_URLS_SOMETIMES), - '#description' => t('This setting affects your applications\' connect_url, callback_url, secure_callback_url, profile_tab_url, and secure_page_tab_url properties.'), + '#description' => t('This setting affects your applications\' website_url, canvas_url, secure_canvas_url, profile_tab_url, and secure_page_tab_url properties.'), '#options' => array( FB_SECURE_URLS_NEVER => t('Never use HTTPS. (I.e. this server does not support it.)'), FB_SECURE_URLS_SOMETIMES => t('Use HTTPS only when Facebook expects a secure URL. (Recommended.)'), Index: fb.module =================================================================== --- fb.module (revision 5294) +++ fb.module (working copy) @@ -1085,14 +1085,14 @@ /** * Will return a human-readable name if the fb_app module supports it, or - * fb_admin_get_app_properties($fb_app) has been called. However we don't + * fb_admin_get_app_info($fb_app) has been called. However we don't * take the relatively expensive step of calling that ourselves. */ function fb_get_app_title($fb_app) { if (isset($fb_app->title)) return $fb_app->title; - elseif (isset($fb_app->application_name)) { - return $fb_app->application_name; + elseif (isset($fb_app->name)) { + return $fb_app->name; } else { return $fb_app->label; Index: fb_app.admin.inc =================================================================== --- fb_app.admin.inc (revision 5288) +++ fb_app.admin.inc (working copy) @@ -18,20 +18,16 @@ // URLs for Facebook events we support. $return['uninstall_url'] = url(FB_APP_PATH_EVENT . '/' . $fb_app->label . "/" . FB_APP_EVENT_POST_REMOVE . '/', array( 'absolute' => TRUE, - 'language' => FALSE, + 'language' => NULL, )); $return['authorize_url'] = url(FB_APP_PATH_EVENT . '/' . $fb_app->label . "/" . FB_APP_EVENT_POST_AUTHORIZE . '/', array( 'absolute' => TRUE, - 'language' => FALSE, + 'language' => NULL, )); } elseif ($op == FB_ADMIN_OP_LIST_PROPERTIES) { - $return[t('Application Name')] = 'application_name'; - $return[t('About URL')] = 'about_url'; - $return[t('Post-Authorize Callback URL')] = 'authorize_url'; - $return[t('Post-Remove Callback URL')] = 'uninstall_url'; - // Learn canvas name regardless of whether fb_canvas is enabled. - $return[t('Canvas Name')] = 'canvas_name'; + $return[t('Application Name')] = 'name'; + $return[t('De-Authorize Callback URL')] = 'deauth_callback_url'; } elseif (($op == FB_ADMIN_OP_LOCAL_LINKS) && isset($fb_app->fba_id)) { // Path to edit this app. @@ -188,11 +184,11 @@ } } // Getting properties confirms apikey and secret. - fb_admin_get_app_properties($fb_app); - if (!$fb_app->application_name) { + fb_admin_get_app_info($fb_app); + if (!$fb_app->name) { // Don't use form_set_error(), as that will prevent the user from saving any data. drupal_set_message(t("Unable to get application properties. Possibly, you've given the wrong id or secret. Possibly, this server is unable to reach facebook's servers. Your application will not work properly!"), 'error'); - $fb_app->application_name = 'UNKOWN'; + $fb_app->name = 'UNKOWN'; } } } @@ -201,8 +197,8 @@ $fb_app = (object)$form_state['values']; $fb_app->data = serialize($fb_app->fb_app_data); - // Get canvas_name, application_name from facebook. - fb_admin_get_app_properties($fb_app); + // Get namespace, name from facebook. + fb_admin_get_app_info($fb_app); $orig_app = $form['#fb_app']; if ($orig_app->fba_id) { @@ -211,11 +207,11 @@ db_query("UPDATE {fb_app} SET label='%s', status = %d, apikey='%s', secret='%s', id='%s', canvas='%s', title='%s',data='%s' WHERE fba_id = %d", $fb_app->label, $fb_app->status, - $fb_app->id, // $fb_app->apikey, deprecated! XXX + $fb_app->id, // $fb_app->apikey no longer used, ID instead. $fb_app->secret, $fb_app->id, - $fb_app->canvas_name, // From facebook, not form. - $fb_app->application_name, // From facebook, not form. + $fb_app->namespace, // From facebook, not form. + $fb_app->name, // From facebook, not form. $fb_app->data, $orig_app->fba_id); @@ -226,7 +222,7 @@ l(t('view apps'), FB_PATH_ADMIN_APPS)); drupal_set_message(t('Saved changes to Facebook application %title (%label).', - array('%title' => $fb_app->application_name, + array('%title' => $fb_app->name, '%label' => $fb_app->label))); // Should we just go ahead and flush the cache here automatically? @@ -239,11 +235,11 @@ db_query("INSERT INTO {fb_app} (label, status, apikey, secret, id, canvas, title, data) VALUES ('%s', %d, '%s', '%s', '%s', '%s', '%s', '%s')", $fb_app->label, $fb_app->status, - $fb_app->id, // $fb_app->apikey, deprecated XXX + $fb_app->id, // $fb_app->apikey no longer used, ID instead. $fb_app->secret, $fb_app->id, - $fb_app->canvas_name, // From facebook, not form. - $fb_app->application_name, // From facebook, not form. + $fb_app->namespace, // From facebook, not form. + $fb_app->name, // From facebook, not form. $fb_app->data); watchdog('fb_app', 'Created Facebook Application %label.', @@ -254,7 +250,7 @@ drupal_set_message(t('Created facebook application %title (%label).', array('%label' => $fb_app->label, - '%title' => $fb_app->application_name))); + '%title' => $fb_app->name))); } if ($fb_app->status) { @@ -326,19 +322,20 @@ if ($fb_app_data['set_app_props']) { if ($fb = fb_api_init($fb_app)) { try { - $result = fb_call_method($fb, 'admin.setAppProperties', array( - 'properties' => json_encode($props), - )); + $result = fb_graph($fb_app->id, $props + array('access_token' => fb_get_token($fb)), 'POST', $fb); + // @todo handle $result != true. + drupal_set_message(t('Note that it may take several minutes for property changes to propagate to all facebook servers.')); if (fb_verbose()) { drupal_set_message(t('Set the following properties for %label application:
!props
', array('%label' => $fb_app->label, '!props' => print_r($props, 1)))); - watchdog('fb_app', 'Set facebook app properties for %label.', - array('%label' => $fb_app->label, + watchdog('fb_app', 'Set facebook app properties for %label.', array( + '%label' => $fb_app->label, ), WATCHDOG_NOTICE, l(t('view apps'), FB_PATH_ADMIN)); } - } catch (Exception $e) { + } + catch (Exception $e) { drupal_set_message(t('Failed to set the following properties for %label application. You may need to manually editing remote settings!
!props
', array('%label' => $fb_app->label, '!props' => print_r($props, 1))), 'error'); fb_log_exception($e, t('Failed to set application properties on Facebook. %props', array('%props' => json_encode($props)))); } Index: fb_app.install =================================================================== --- fb_app.install (revision 5288) +++ fb_app.install (working copy) @@ -70,7 +70,7 @@ 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, - 'description' => 'We learn this from facebook app properties', + 'description' => 'We learn this from facebook app properties, facebook now calls it namespace', ), 'title' => array( 'type' => 'varchar', @@ -228,4 +228,3 @@ } return $ret; } - Index: fb_canvas.admin.inc =================================================================== --- fb_canvas.admin.inc (revision 5288) +++ fb_canvas.admin.inc (working copy) @@ -25,18 +25,19 @@ // Paving the way to make URL alters optional. $callback_url = url('', array('absolute' => TRUE)); } - $return['callback_url'] = $callback_url; + $return['canvas_url'] = $callback_url; if (variable_get(FB_VAR_SECURE_URLS, FB_SECURE_URLS_SOMETIMES) >= FB_SECURE_URLS_SOMETIMES) { - $return['secure_callback_url'] = str_replace('http://', 'https://', $callback_url); + $return['secure_canvas_url'] = str_replace('http://', 'https://', $callback_url); } if (variable_get(FB_VAR_SECURE_URLS, FB_SECURE_URLS_SOMETIMES) <= FB_SECURE_URLS_SOMETIMES) { - // Make callback_url HTTP, even if we administer drupal via HTTPS. - $return['callback_url'] = str_replace('https://', 'http://', $return['callback_url']); + // Make canvas_url HTTP, even if we administer drupal via HTTPS. + $return['canvas_url'] = str_replace('https://', 'http://', $return['canvas_url']); } + } elseif ($op == FB_ADMIN_OP_LIST_PROPERTIES) { - $return[t('Callback URL')] = 'callback_url'; - $return[t('Secure Callback URL')] = 'secure_callback_url'; + $return[t('Canvas URL')] = 'canvas_url'; + $return[t('Secure Canvas URL')] = 'secure_canvas_url'; } } Index: fb_connect.admin.inc =================================================================== --- fb_connect.admin.inc (revision 5288) +++ fb_connect.admin.inc (working copy) @@ -10,29 +10,27 @@ */ function fb_connect_fb_admin($op, $data, &$return) { if ($op == FB_ADMIN_OP_SET_PROPERTIES) { - $return['connect_url'] = fb_connect_get_connect_url($data['fb_app']); + $return['website_url'] = fb_connect_get_website_url($data['fb_app']); if (variable_get(FB_VAR_SECURE_URLS, FB_SECURE_URLS_SOMETIMES) == FB_SECURE_URLS_ALWAYS) { - $return['connect_url'] = str_replace('http://', 'https://', $return['connect_url']); + $return['website_url'] = str_replace('http://', 'https://', $return['website_url']); } else { - $return['connect_url'] = str_replace('https://', 'http://', $return['connect_url']); + $return['website_url'] = str_replace('https://', 'http://', $return['website_url']); } } elseif ($op == FB_ADMIN_OP_LIST_PROPERTIES) { - $return[t('Connect URL')] = 'connect_url'; + $return[t('Webiste URL')] = 'website_url'; } } /** - * Convenience method to get an apps connect URL. - * + * Convenience method to get an app's website URL. */ -function fb_connect_get_connect_url($fb_app) { +function fb_connect_get_website_url($fb_app) { // absolute URL with no rewriting applied global $base_url; return $base_url . '/'; - } @@ -85,4 +83,3 @@ ); return system_settings_form($form); } - Index: fb_devel.module =================================================================== --- fb_devel.module (revision 5288) +++ fb_devel.module (working copy) @@ -232,6 +232,7 @@ // server URL sanity check // This is an expensive test, because it invokes api_client. try { + // @todo admin.getAppProperties deprecated. Use graph API instead. $props = $fb->api(array( 'method' => 'admin.getAppProperties', 'access_token' => fb_get_token($fb), @@ -636,6 +637,7 @@ try { // app properties $token = fb_get_token($_fb); + // @todo: getAppProperties deprecated. Use graph API instead. $props = $_fb->api(array( 'method' => 'admin.getAppProperties', 'properties' => 'about_url', 'application_name', Index: fb_tab.admin.inc =================================================================== --- fb_tab.admin.inc (revision 5288) +++ fb_tab.admin.inc (working copy) @@ -24,36 +24,24 @@ // Paving the way to make URL alters optional. $callback_url = url('', array('absolute' => TRUE)); } - $return['profile_tab_url'] = $callback_url . FB_TAB_PATH_VIEW; + $return['page_tab_url'] = $callback_url . FB_TAB_PATH_VIEW; if (variable_get(FB_VAR_SECURE_URLS, FB_SECURE_URLS_SOMETIMES) >= FB_SECURE_URLS_SOMETIMES) { - $return['secure_page_tab_url'] = str_replace('http://', 'https://', $return['profile_tab_url']) . '/'; // Must end with '/' ??? + $return['secure_page_tab_url'] = str_replace('http://', 'https://', $return['page_tab_url']) . '/'; // Must end with '/' ??? } if (variable_get(FB_VAR_SECURE_URLS, FB_SECURE_URLS_SOMETIMES) <= FB_SECURE_URLS_SOMETIMES) { - $return['profile_tab_url'] = str_replace('https://', 'http://', $return['profile_tab_url']); + $return['page_tab_url'] = str_replace('https://', 'http://', $return['page_tab_url']); } } else { - $return['profile_tab_url'] = ''; + $return['page_tab_url'] = ''; } - if ($config['edit_url']) { - // http://forum.developers.facebook.net/viewtopic.php?id=88920 - $return['edit_url'] = url($config['edit_url'], array( - 'absolute' => TRUE, - 'fb_canvas' => $fb_app->label, // @TODO make canvas optional - ));; - } - else { - $return['edit_url'] = ''; - } } elseif ($op == FB_ADMIN_OP_LIST_PROPERTIES) { - $return[t('Profile Tab Name')] = 'tab_default_name'; - $return[t('Profile Tab URL')] = 'profile_tab_url'; + $return[t('Page Tab Name')] = 'page_tab_default_name'; + $return[t('Page Tab URL')] = 'page_tab_url'; $return[t('Secure Page Tab URL')] = 'secure_page_tab_url'; - $return[t('Profile Tab Edit URL')] = 'edit_url'; - $return[t('Installable')] = 'installable'; } }