Jump to content

Help with Facebook share script, link not displaying properly.


shelbyit

Recommended Posts

Hi all,

 

I'm not great with PHP and I have this one problem that I hope you can help with.

 

I have a script that generates an URL. The output string is $shorturl and displays properly when I echo it using

<?php echo '$shorturl' ?>

.

 

However, when I try the following script for a Facebook share button

<fb:share-button>
<a name="fb_share" type="button" share_url="<?php echo '$shorturl' ?>" href="http://www.facebook.com/sharer.php" layout="button_count">Share</a><script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script>	
</fb:share-button>

 

The resulting URL it produces is: http://</?php+echo+%27http%3A%2F%2Fshelb...

 

Any idea's?

 

Thank you!

Link to comment
Share on other sites

I'm not sure how the facebook API works, but it looks like you only need to put the variable in there.

Try this:

<a name="fb_share" type="button" share_url="$shorturl" href="http://www.facebook.com/sharer.php" layout="button_count">Share</a><script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script>	

 

You may have to also use urldecode() on $shorturl before it's used in the sharebutton code.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.