Posts

Post as Facebook Page via Gianism

Gianism 3.0.6 has been released! This version is between bug fix and new feature.

Gianism can post to Facebook. To enable this feature, you have to set up like below:

Setting screen is like above.

  1. On Gianism setting scree, enable “Use Facebook API”.
  2. New tab “Facebook API” become available. There click “Get Token”. You can choose read only or writable.
  3. Successfully retrieved token, account list is displayed. You can choose facebook page.
  4. Now page token are retrieved, you can do something via API.
<?php
// After setup, you can get token ready API object.
$api = gianism_fb_page_api();
if ( is_wp_error( $fb ) ) {
  // Oops, failed.
  return false;
}
// After you got Graph API, do something.
// Wrap with Try-Catch for precaution.
try {
  $feeds = $fb->get( "me/feed" );
  // Use GraphEdge method.
  $status = '';
  foreach ( $feeds->getGraphEdge() as $fb_post ) {
    $status = $fb_post->getField( 'message' );
    break;
  }
  return $status;
} catch ( Exception $e ) {
  return false;
}

$api  object is an instance of Facebook\Facebook. Please refer to Facebook PHP SDK Reference.

Why we updated

Well, we thought Gianism has feature of “publishing as page”. But we implemented “publish to page as your personal account”.

For example, my account is Takahashi Fumiki. If Gianism posts to Facebook via this account, error occurs because of no permission. If you have succeeded, it means that Takahashi Fumiki posts to Gianism.info page, so this doesn’t suit for your aim.

Generally, people connect WordPress and Facebook page to integrate site identity. So if you want to share something to your Facebook page, it’s better to post as Facebook page than as you.

Of course, just to post “New post is published!”, Jetpack is enough. Do something more special.

Implementation

I tried to add new feature to my site.

An image will be generated with text.

This feature is created for Instagram, but Instagram API now disabled image post :p

How about it? Users tend to hesitate to share via their account, but it’s possible that they share, retweet or give if our facebook page shares or mentions to them with chosen content by themselves? If you have any idea, please share it!