$api_key, 'secret' => $secret, 'cookie' => true, ) ); if((!isset($_REQUEST['app_tab'])) && (isset($_REQUEST['is_invite']))) { // this is the invite page if(isset($_POST["ids"])) { // this means we've already added some stuff echo "
Thank you for inviting ".sizeof($_POST["ids"]) ." of your friends to ". $app_name .".

\n"; echo "

Click here to return to ".$app_name.".

"; } else { // Retrieve array of friends who've already added the app. $fql = 'SELECT uid FROM user WHERE uid IN (SELECT uid2 FROM friend ' . 'WHERE uid1='. $data["user_id"] .') AND is_app_user = 1'; $params = array( 'method' => 'fql.query', 'query' => $fql, ); try { $_friends = $facebook->api($params); } catch (FacebookApiException $e) { if($wpbook_show_errors) { $wpbook_message = 'Caught exception in getting friends for user: ' . $e->getMessage() .'Error code: '. $e->getCode(); wp_die($wpbook_message,'WPBook Error'); } // end if for show errors } // Extract the user ID's returned in the FQL request into a new array. $friends = array(); if (is_array($_friends) && count($_friends)) { foreach ($_friends as $friend) { $friends[] = $friend['uid']; } } // Convert the array of friends into a comma-delimeted string. $friends = implode(',', $friends); // Prepare the invitation text that all invited users will receive. $content = " has started using " ."" . $app_name ." and thought you should try it out!\n" .""; echo 'Invite Friends'; echo ''; echo ''; echo ''; } // end of the else for $_POST["ids"] } // end of the if for $_REQUEST['is_invite'] // Done with potential invite page, now do permissions if((!isset($_REQUEST['app_tab'])) && (!isset($_REQUEST['is_invite'])) && (isset($_REQUEST['is_permissions']))) { // we're looking for extended permissions $receiver_url = WP_PLUGIN_URL . '/wpbook/theme/default/xd_receiver.html'; ?> <?php bloginfo('name'); ?> :: Facebook Blog Application

This page is where you can check and grant extended permissions, which enable WPBook to publish to your personal wall and/or to the walls of fan pages.

The Facebook profile ID you are currently logged in to Facebook as is . You have defined as your Facebook user id in WPBook Settings.

Your Facebook Profile ID must match the ID with which you are logged in to Facebook, or else an access token will not be stored and publishing to Facebook will fail. Please update the "YOUR Facebook Profile ID" setting in WPBook settings to match the userid shown above.

'; } ?>

FB profile has granted these permissions: 'fql.query', 'query' => $fql, ); try { $my_permissions = $facebook->api($params); } catch (FacebookApiException $e) { if($wpbook_show_errors) { $wpbook_message = 'Caught exception in getting permissions for user: ' . $e->getMessage() .'Error code: '. $e->getCode(); wp_die($wpbook_message,'WPBook Error'); } // end if for show errors } ?>

  • offline_access -
  • read_stream -
  • publish_stream -
  • manage_pages -

An access token for this user has been stored.

'; } else { echo '

Error: No access token has been stored for this user -'; echo 'probably due to a misconfiguration. Check to see that the ProfileID '; echo 'with which you are logged in to Facebook matches the one set in '; echo 'WPBook settings, as listed above

'; } if((!empty($wpbookAdminOptions['fb_page_target'])) && ($wpbookAdminOptions['stream_publish_pages'] == "true")) { echo "

You've indicated you wish to publish to this page: ". $wpbookAdminOptions['fb_page_target'] ."

"; $fb_response = $facebook->api('/me/accounts/'); foreach($fb_response['data'] as $page) { if ($page['id'] == $wpbookAdminOptions['fb_page_target']) { $my_wp_page_name = $page['name']; if($page['access_token']) { update_option('wpbook_page_access_token',$page['access_token']); echo '

An access token corresponding to this page has been stored.

'; } else { echo '

ERROR: No access token corresponding to this page was '; echo 'found or stored. This likely means that either: '; echo '

  • The PageID is entered incorrectly in WPBook settings, or
  • '; echo '
  • The Facebook profile currently logged in has not granted the '; echo '"manage_pages" permission appropriately, or
  • '; echo '
  • The Facebook profile logged in (and for which an access token '; echo 'has been stored) is not eligible to grant manage_pages for the page '; echo 'in question (not an admin).

'; } } } } // end if fb_page_target is set if((!empty($wpbookAdminOptions['wpbook_target_group'])) && ($wpbookAdminOptions['stream_publish_pages'] == "true")) { echo "

You've indicated you wish to publish to this group: ". $wpbookAdminOptions['wpbook_target_group'] ."

"; if(($my_permissions[0][publish_stream] == 1) && ($my_permissions[0][offline_access] == 1)) { echo '

The user access token includes publish stream and offline access permissions.

'; } else { echo '

ERROR: The user access token does not include publish stream '; echo 'and offline access permissions.

'; } } // end if wp_target_group is set ?>

To correct any of these, " target="_top">Grant or re-grant permissions for your userid. (This is required if you intend to publish to your personal wall OR any fan pages.)

<?php bloginfo('name'); ?> :: Facebook Blog Application

Thank You!

This application has been added to your page's profile.

"; echo "

You can return to your page to see the updated information.

"; echo "

Thanks!

"; echo ""; } ?>
Invite Friends '; echo '
'. $invite_link .'
'; } echo '

'. get_bloginfo('name') .'

'; if(($show_pages == "true") && ($show_pages_menu == "true")){ echo '
  • Pages:
  • '; if ($exclude_pages_true == "true"){ wp_list_pages("sort_column=menu_order&depth=1&title_li=&exclude=$exclude_pages_list"); } else { wp_list_pages("sort_column=menu_order&depth=1&title_li="); } echo '
'; } //end show pages menu echo '
'; if(is_page()){ // is a page echo '
'; echo '

'. the_title() .'

'; if (have_posts()) : while (have_posts()) : the_post(); the_content(); endwhile; else: echo '

'; _e('Sorry, page does not exist.'); echo '

'; endif; echo '
'; } // end if is_page() else { if(is_archive()){ echo '
'; if (is_category()) { echo '

'; printf( __('You are currently browsing the %1$s archives for the \'%2$s\' category.'), $app_name, single_cat_title('', false) ); echo '

'; } elseif (is_day()) { echo '

You are currently browsing the '. $app_name .' archives for the day '. the_time('l, F jS, Y') .'.

'; } elseif (is_month()) { echo '

You are currently browsing the '. $app_name .' archives for '. the_time('F, Y') .'.

'; } elseif (is_year()) { echo '

You are currently browsing the '. $app_name .' archives for the year '. the_time('Y') .'.

'; } elseif (is_search()) { echo '

You have searched the '. $app_name .' archives for "'. wp_specialchars($s) .'".

'; } elseif (isset($_REQUEST['paged']) && !empty($_REQUEST['paged'])) { echo '

You are currently browsing the '. $app_name.' archives.

'; } elseif(is_tag()){ echo '

'; printf( __('You are currently browsing the %1$s archives for the \'%2$s\' tag.'), $app_name, single_tag_title('', false) ); echo '

'; } } // end of if is_archive() ?>
is_single || $wp_query->is_singular) { previous_post_link('« Previous Post: %link
', '%title',FALSE,''); next_post_link('Next Post: %link »
', '%title',FALSE,''); } //end if single ?>

'.custom_header_footer($custom_header,$timestamp_date_format,$timestamp_time_format) .'
'); } // end if for showing customer header if(($enable_share == "true" || $enable_external_link == "true") && ($links_position == "top")) { echo '

'; if($enable_share == "true"){ ?> View post on '; } // end links_position _top the_content(); // echo custom footer if(($show_custom_header_footer == "footer") || ($show_custom_header_footer == "both")){ echo('

'); } // endif for footer // get share link if(($enable_share == "true" || $enable_external_link == "true") && ($links_position == "bottom")) { echo '

'; if($enable_share == "true"){ ?> View post on '; } // end if for enable share, external, bottom echo '

'; comments_template(); endwhile; // while have posts $wpbook_next_page = get_next_posts_link(); $wpbook_prev_page = get_previous_posts_link(); if($wpbook_prev_page || $wpbook_next_page) { echo '

More Posts

'; echo '

'; if ($wpbook_prev_page) echo $wpbook_prev_page; if ($wpbook_prev_page && $wpbook_next_page) echo ' | '; if ($wpbook_next_page) echo $wpbook_next_page; echo '

'; } endif; // if have posts echo '
'; } //end if else for if_page() - blog or archive if($show_pages == "true" && $show_page_list=="true"){ ?>

This Facebook Application powered by the WPBook plugin for WordPress.