0

I am trying to use the Facebook Javascript SDK feed dialogue to create a share button on my app. I am using the php sdk on my app which is a codeigniter build deployed on Facebook.

I used the following on my php page.

       <script type="text/javascript">
                function share(){
                FB.ui({
                method: 'feed',
                link: 'https://apps.facebook.com/myapp',
                caption: 'An example caption',
                }, function(response){});
                }
        </script>

   <button  onclick="share()">Share this Video</button>

When I attempt to run this on my canvnas page, (when button is clicked), I get a pop up with error:

An error occurred. Please try later

.

On localhost, when I try this I get a pop up with error:

API Error Code: 191 API Error Description: The specified URL is not owned by the application Error Message: redirect_uri is not owned by the application.

I've been looking at other question with similar problems but now luck in getting this working.

How can I fix my code to work so that when the button is clicked, I get a prompt to publlish to my wall, and enter a message.

Can this be done with the php?

EDIT:

Did some checking, does this fb.ui need to be used with this, or can it be used?

user3237078
  • 141
  • 1
  • 1
  • 6

1 Answers1

0

Try this. It working fine form me.

Script:

<script src="http://connect.facebook.net/en_US/all.js" type="text/javascript"></script>
<script type="text/javascript">
(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1&appId=1234567890";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>

FB Button:

  <div class="fb-share-button" id="fb-root"  data-href="<?php echo $yourlink; ?>" data-type="button_count"></div>

Put this after body tag or before script.

<div id="fb-root"></div>
Gowri
  • 1,832
  • 3
  • 29
  • 53
  • I was actually using this before and it worked great for sharing, however I need to implement custom code when the button is clicked which is why i was looking at the js feed dialog. Also this just shares the link, and just posts the link itself on my wall, doesn't look good. Is there a way to add some image or other message with this way. Maybe the link and image for the app itself, because the link I am passing to share is dynamic. If so then I could go back to using this I guess. Can it be done? – user3237078 Jan 28 '14 at 09:35