WordPress.org

Plugin Directory

Changeset 190515


Ignore:
Timestamp:
01/06/10 08:33:04 (8 years ago)
Author:
ahupp
Message:

[wp-fbconnect] Update to use stream.publish.

Summary:
This diff updates wp-fbconnect to use the stream.publish api. An
example of the produced feedform is here:

http://pixels-pixels-pixels.intern.facebook.com/intern/pixelcloud/image.php?id=8373

An excerpt of the post is now included in the feed story as well.

Blame Rev:

Task ID: #

Reviewers: lshepard, mvernal

Test Plan:
Installed WP2.9.1, logged out of FB. Verified I could add the plugin,
login to wordpress with facebook, and post a comment. Posting a
comment produces a feedform with appropriate content and the story is
posted on my wall.

Verify config menu still works.

DiffCamp Revision:

Revert Plan:

Database Impact:

Memcache Impact:

Other Notes:

EImportant:

  • begin *PUBLIC* platform impact section -

Bugzilla: #

  • end platform impact -

DiffCamp Revision: 82315

Location:
wp-facebookconnect/trunk
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • wp-facebookconnect/trunk/config.php

    r88194 r190515  
    1111define('FBC_DEBUG_LOGIN_HEADER', false); 
    1212 
    13 /* 
    14   In each of the templates below, the first template is for a single 
    15   story and the second template is for an aggregated story. 
    16  */ 
    17 $fbc_one_line_stories = array( 
    18   '{*actor*} commented on the <a href="{*blog-url*}">{*blog-name*}</a> blog post "<a href="{*post-url*}">{*post-title*}</a>".', 
    19   '{*actor*} posted comments on <a href="{*blog-url*}">{*blog-name*}</a>.' 
    20 ); 
    2113 
    22  
    23 $fbc_short_story_templates = array( 
    24   array('template_title' => 
    25         '{*actor*} commented on the <a href="{*blog-url*}">{*blog-name*}</a> blog post "<a href="{*post-url*}">{*post-title*}</a>".', 
    26         'template_body' => ''), 
    27    array('template_title' => 
    28          '{*actor*} posted comments on <a href="{*blog-url*}">{*blog-name*}</a>.', 
    29          'template_body' => '') 
    30 ); 
    31  
  • wp-facebookconnect/trunk/fbconnect.js

    r117347 r190515  
    1111 
    1212  init : function(api_key, plugin_path, 
    13                   template_bundle_id, home_url, 
    14                   wp_user, app_config) { 
     13                  home_url, wp_user, app_config) { 
    1514 
    1615    if (!api_key) { 
     
    3332 
    3433    FBConnect.plugin_path = plugin_path; 
    35     FBConnect.template_bundle_id = template_bundle_id; 
    3634    FBConnect.wp_user = wp_user; 
    3735 
     
    6664   */ 
    6765  setup_feedform : function() { 
    68  
    69     if (!FBConnect.template_bundle_id) { 
    70       FBConnect.error("no template id provided"); 
    71       return; 
    72     } 
    7366 
    7467    var comment_form = ge('commentform'); 
     
    118111  show_comment_feedform : function() { 
    119112 
    120     var template_data = { 
    121         'post-url': window.location.href, 
    122         'post-title': FBConnect.article_title, 
    123         'blog-name': FBConnect.blog_name, 
    124         'blog-url': FBConnect.home_url 
    125     }; 
    126  
    127113    var comment_text = ''; 
    128114 
     
    147133    } 
    148134 
    149     FB.Connect.showFeedDialog(FBConnect.template_bundle_id, 
    150                               template_data, 
    151                               null, // template_ids 
    152                               null, // body_general 
    153                               null, // story_size (deprecated) 
    154                               FB.RequireConnect.promptConnect, // require_connect 
    155                               function() { 
    156                                 commentform.submit(); 
    157                               }, 
    158                               'Your comment: ', 
    159                               {value: comment_text}); 
     135    FB.Connect.streamPublish( 
     136      comment_text, // user_message 
     137      {  
     138        name: FBConnect.article_title, 
     139        href: window.location.href, 
     140        caption: 'A post on the blog ' + FBConnect.blog_name, 
     141        description: "\"" + FBConnect.excerpt + "\"" 
     142      }, // attachment 
     143      null, // action links 
     144      null, // target_id 
     145      'My Comment', // prompt 
     146      function() { 
     147        // unconditional 
     148        commentform.submit(); 
     149      } 
     150    ); 
    160151 
    161     // submit handled by showFeedDialog 
     152    // submit handled by streamPublish 
    162153    return false; 
    163154 
  • wp-facebookconnect/trunk/fbconnect.php

    r129757 r190515  
    3131define('FBC_APP_KEY_OPTION', 'fbc_app_key_option'); 
    3232define('FBC_APP_SECRET_OPTION', 'fbc_app_secret_option'); 
    33 define('FBC_BUNDLE_OPTION', 'fbc_template_bundle_id'); 
    3433define('FBC_LAST_UPDATED_CACHE_OPTION', 'fbc_last_updated_cache_option'); 
    3534define('FBC_REMOVE_NOFOLLOW_OPTION', 'fbc_remove_nofollow_option'); 
     
    176175  // you are using php4. 
    177176  try { // ATTENTION: This plugin is not compatible with PHP4 
    178     $api_client->feed_getRegisteredTemplateBundles(); 
     177    $api_client->admin_getAppProperties(array('application_name')); 
    179178    $success = true; 
    180179  } catch(Exception $e) { 
     
    232231  update_option(FBC_APP_KEY_OPTION, null); 
    233232  update_option(FBC_APP_SECRET_OPTION, null); 
    234   update_option(FBC_BUNDLE_OPTION, null); 
    235233} 
    236234 
     
    279277        update_option(FBC_REMOVE_NOFOLLOW_OPTION, $remove_nofollow); 
    280278 
    281         $force_template_reload = isset($_POST['force_template_reload']); 
    282         fbc_register_templates($force_template_reload); 
    283279        fbc_set_callback_url(); 
    284280 
     
    316312                 fbc_tag_input('text', FBC_APP_SECRET_OPTION, $app_secret, 50)); 
    317313 
    318   echo fbc_tag_p(__('Force Reload of Template Bundle from config.php (resets ID):', 
    319                  'mt_trans_domain'), 
    320                  fbc_tag_input('checkbox', 'force_template_reload', 'true')); 
    321  
    322314  echo fbc_tag_p(__('Strip nofollow from Facebook comment author links:', 
    323315                 'mt_trans_domain'), 
     
    327319  echo fbc_tag_p(__('Last user data update:', 'mt_trans_domain'), 
    328320                 get_option(FBC_LAST_UPDATED_CACHE_OPTION)); 
    329   echo fbc_tag_p(__('Template Bundle ID:', 'mt_trans_domain'), 
    330                  get_option(FBC_BUNDLE_OPTION)); 
    331321 
    332322?> 
     
    366356  $plugin_dir = this_plugin_path() . '/'; 
    367357 
    368   $bundle_id = get_option(FBC_BUNDLE_OPTION); 
    369358  $site_url = get_option('siteurl'); 
    370359 
    371360  $user = wp_get_current_user(); 
    372361 
    373   $init = "FBConnect.init('%s', '%s', '%s', '%s', %d, FBConnect.appconfig_%s);"; 
     362  $init = "FBConnect.init('%s', '%s', '%s', %d, FBConnect.appconfig_%s);"; 
    374363  fbc_footer_register(sprintf($init, 
    375364                              get_option(FBC_APP_KEY_OPTION), 
    376365                              $plugin_dir, 
    377                               $bundle_id, 
    378366                              $site_url, 
    379367                              $user->ID, 
     
    498486    $article_title = ltrim(wp_title($sep='',$display=false,$seplocation='')); 
    499487 
    500     fbc_footer_register(sprintf("FBConnect.blog_name = '%s';", 
    501                            addslashes($blogname))); 
    502     fbc_footer_register(sprintf("FBConnect.article_title = '%s';", 
    503                            addslashes($article_title))); 
     488    global $post; 
     489 
     490    $excerpt = strip_tags($post->post_content); 
     491 
     492    $excerpt_len = 1024; 
     493    if (strlen($excerpt) > $excerpt_len) { 
     494       $excerpt = substr($excerpt, 0, $excerpt_len) . "..."; 
     495    } 
     496 
     497    fbc_set_js_var('excerpt', $excerpt); 
     498    fbc_set_js_var('blog_name', $blogname); 
     499    fbc_set_js_var('article_title', $article_title); 
    504500 
    505501    fbc_footer_register("FBConnect.setup_feedform();"); 
    506502  } 
     503} 
     504 
     505function fbc_set_js_var($name, $value) { 
     506  fbc_footer_register('FBConnect.'.$name .'='.json_encode($value)); 
    507507} 
    508508 
     
    564564} 
    565565 
    566 function fbc_register_templates($force=false) { 
    567  
    568   $bundle_id = get_option(FBC_BUNDLE_OPTION); 
    569   if ($bundle_id && !$force) { 
    570     return $bundle_id; 
    571   } 
    572  
    573   global $fbc_short_story_templates; 
    574   global $fbc_one_line_stories; 
    575  
    576   $bundle_id = fbc_api_client()->feed_registerTemplateBundle( 
    577                  $fbc_one_line_stories, 
    578                  $fbc_short_story_templates, 
    579                  null, 
    580                  null 
    581                ); 
    582  
    583   update_option(FBC_BUNDLE_OPTION, "$bundle_id"); 
    584  
    585   return $bundle_id; 
    586  
    587 } 
    588566 
    589567/* automatically set the callback url on the app so the user doesn't 
  • wp-facebookconnect/trunk/readme.txt

    r120739 r190515  
    11=== WP-FacebookConnect === 
    22Requires at least: 2.5 
    3 Tested up to: 2.6 
    4 Stable Tag: 1.1.2 
    5 Version: 1.1.2 
     3Tested up to: 2.9.1 
     4Stable Tag: 1.2.0 
     5Version: 1.2.0 
    66Tags: comments, facebook 
    77Contributors: ahupp 
     
    1515 * Publish comments to the newsfeed 
    1616 * Comment avatars display Facebook profile photos 
     17 
     18What's New: 
     19 
     20  v1.2: 
     21    - Feed stories are now published with the stream.publish API call. 
     22  Stories also include an excerpt from the post. 
    1723 
    1824== Installation == 
     
    4955See config.php and the Settings page for more configuration and 
    5056customization options. 
     57 
     58== Upgrades == 
     59 
     60Please see the `CHANGES` file for information that may be useful when 
     61upgrading from an older release. 
    5162 
    5263== A note on 'nofollow' == 
Note: See TracChangeset for help on using the changeset viewer.