Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7894131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:18:56+00:00 2026-06-03T07:18:56+00:00

I am using Nick Baker’s (webtechnick) CakePHP / Facebook plugin which is awesome and

  • 0

I am using Nick Baker’s (webtechnick) CakePHP / Facebook plugin which is awesome and works great, however I have a question that I can’t seem to even come close to answer for.

How would I bypass the use of a share button and share directly through an action?

For instance, I make a post through my site and the post adds to the DB as it should, it also shoots a post to the logged in users Twitter account through the action. How can I also have this action handle sharing it to my FB account (connection has already been made).? I tried the first thing I think anyone would obviously try $this->Facebook->share() directly in the action, too no avail…

Any thoughts or solutions would be of great help…

UPDATE AFTER ANSWER

Thx for the help spooney. I voted your answer up because you are 100% spot on from what I can tell. I am loading the JS SDK.

    function init($options = null, $reload = true) {
        if (empty($options)) {
            $options = array();
        }
        if ($appId = FacebookInfo::getConfig('appId')) {
            $session = json_encode($this->Session->read('FB.Session'));
            if ($reload) {
                $callback = "FB.Event.subscribe('auth.login',function(){window.location.reload()});";
            } else {
                $callback = "if(typeof(facebookReady)=='function'){facebookReady()}";
            }
            $callback .= "FB.Event.subscribe('auth.logout',function() {window.location = '/bastards/users/logout'});";
            $init = '<div id="fb-root"></div>';
            $init .= $this->Html->scriptBlock(
<<<JS
window.fbAsyncInit = function() {
    FB.init({
        appId : '{$appId}',
        status : true, // check login status
        cookie : true, // enable cookies to allow the server to access the session
        xfbml : true, // parse XFBML
        oauth : true // use Oauth
    });
    {$callback}
};
(function() {
    var e = document.createElement('script');
    e.src = document.location.protocol + '//connect.facebook.net/{$this->locale}/all.js';
    e.async = true;
    document.getElementById('fb-root').appendChild(e);
}());
JS
            , $options);
            return $init;
        } else {
            return "<span class='error'>No Facebook configuration detected. Please add the facebook configuration file to your config folder.</span>";
        }
    }

I have no problem pulling in the user information and working with all that. I have accomplished posting to FB from my site, but it was only through a link, using FB.ui…

    <a href="#" onClick="publishStory();" class="sendFeed"><br><font style="color:#FFF; text-decoration:none;padding-left:27px;">post to wall</font></a><br>
<script>
function publishStory() {
  FB.ui({
    method: 'feed',
    name: 'message name',
    caption: 'message caption ',
    description: 'description goes here',
    link: 'the url current page',
    picture: 'if you want to add an image'
  }, 
  function(response) {
    console.log('publishStory response: ', response);
  });
  return false;
}
</script>

I have tried replacing the code above with…

    <a href="#" onClick="publishStory();" class="sendFeed"><br><font style="color:#FFF; text-decoration:none;padding-left:27px;">post to wall</font></a><br>
<script>
function publishStory() {
  var body = 'Reading JS SDK documentation';
FB.api('/me/feed', 'post', { message: body }, function(response) {
  if (!response || response.error) {
    alert('Error occured');
  } else {
    alert('Post ID: ' + response.id);
  }
});
}
</script>

But it errors everytime.

I should also throw in there that the post on the users FB wall isn’t really coming from the site persay, it’s a post from the user on their own wall basically stating, “I made a post on ladala.com, you should go check it out at .”

So now I’m at the point that I need to figure out how to run FB.ui through the action that submits the post.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T07:18:57+00:00Added an answer on June 3, 2026 at 7:18 am

    Based on our conversation, I figured I would just put a more complete description in an answer.

    You can fire a share call using the JavaScript SDK.

    First, you would need to load the JavaScript SDK as described in the Loading section of https://developers.facebook.com/docs/reference/javascript/.

    Once loaded into your page, the two calls you want to look at are FB.getLoginStatus, and FB.api. FB.getLoginStatus will give you back a response telling you if the user is logged in to facebook, and if they have approved your application. This link will describe the functionality of getLoginStatus, but in short, you need to check for response.connected(and then possibly do another call to confirm a user’s permissions, if required).

    If the user is logged in and has approved your app, you can then attempt to make an API call using FB.api. Keep in mind to do this, you will likely need the user to have allowed the publish_stream permission.

    Your code would look something like this:

    //Do FB initialization
    FB.getLoginStatus(function(response) {
      if (response.status === 'connected') {
        FB.api('/me/feed', 'post', { message: body }, function(response) {
          if (!response || response.error) {
            //Post was successful
          }
        });
      }
    });
    

    This can be triggered any way you want. On page load, on click, on completion of some other event, etc.

    Keep in mind this is just one way to implement this. Also, if you are trying to share something with your FB application, and it is not working, you should confirm that you have all the permissions required to do so.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using CakePHP and Nick Baker's Facebook Plugin, and I am trying to
Currently i have started using Nick Jhonshon's bloggart on appengine, later i do want
I am trying to implement facebook Connect to my cakephp Application. i am using
Say I have a social network which accepts: short url's using the nickname: e.g.
Using C# for ASP.NET and MOSS development, we often have to embed JavaScript into
So I'm using the jQuery date picker, and it works well. I am using
I want following type of URL using cakephp. http://localhost/project1/controller1/action1/[{user_id:1,udid:,msg:,nick_n:Danis,post_t:2011-10-21 12:15:00,source:A}]/50 where [{user_id:1,udid:,msg:,nick_n:Danis,post_t:2011-10-21 12:15:00,source:A}] and
I'm trying to install Ruby 1.9.3 using rvm. However, when I type: rvm install
I'm making a C# application which is using GameSpy C code (the GP part).
This is a follow-up question to this one .. Thanks to Nick Lockwood, I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.