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!

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.