Jump to content

help with my coding... re.facebook


Zugzwangle

Recommended Posts

Hi,

I'm having problems with my phpbb forum/facebook coding. I have recently put Facebook Share links in my forum...

 

The facebook 'Share' links(buttons), are attached to every post viewable within th eforum, and link to:

http://www.facebook.com/sharer.php?u=http://www.mywebsite.com/facebook/share-fb.php?postNo=" . $postrow[$i]['post_id'].'&title='.$userdata['username'].'%20on%20facebook!!'

--> where

'$userdata['username']' username of forum user

..and

'$postrow[$i]['post_id']' = the id of the forum post, to be processed by share-fb.php

 

 

So as according to here:

http://developers.facebook.com/docs/share

under the Basics section, I will be able to control the thumbnail, title and content from

You can control the exact title, description, and thumbnail that Facebook Share uses by adding the following meta tags to the <head> element in your page:

So the url looks like this:

http://www.anclchess.net/facebook/share.php?postNo=65914&title=My%20Names%20on%20facebook!!Title%20of%20post

 

There are 2 major problems.

1) I am passing the post number identity via URL.. which means anyone wanting to view posts they may not have permissions to view, would simply need to change the share.php?postNo=65914&title= and they would have access..

and

2) The the thumbnail, title and content don't seem to work.. I cant figure out why.. see below

This is 'share-fb.php':

<?php

define('IN_PHPBB', true);  // allows infomation to be passed to external page, such as '$userdata['username'] '(username)
$phpbb_root_path = '../forum/';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);

//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
//
// End session management
//
?>
<?php

$postIdent = $_GET['postNo']; // gets forum post identity from URL, to then later query.. \\
$titleIdent = $_GET['title']; // gets title of post from URL too \\

if($userdata['session_logged_in'])
{

//echo'Hello ' . $userdata['username'] . '. The facebook system is not yet up-and-running. Please try later.<br>'; // <-works \\
$sql = "SELECT post_id, post_subject, post_text FROM phpbb_posts_text WHERE post_id='$postIdent'";
if( !($result = $db->sql_query($sql)) )
{
	message_die(CRITICAL_ERROR, "Could not query config information", "", __LINE__, __FILE__, $sql);
}

while ( $row = $db->sql_fetchrow($result) ) // executes database query \\
{
	$postSubject = $row['post_subject'];
	$postText = $row['post_text'];

}
$pattern = '#\[[^\]]+\]#';
$postTextFormat = preg_replace($pattern, '', $postText);  // this search and replaces the forum square brackets code such as: '[ url ]' & '[ /url ]' content 
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title> // left empty \\ 
<script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" 
        type="text/javascript">
</script>
<meta name="title" content="<?php echo echo $titleIdent; ?>" /> // this doesnt work - I don't know why. The variables work in the <body> but not here \\
<meta name="description" content="<?php echo $postSubject.$postTextFormat; ?>" /> 
<link rel="image_src" href="http://www.mywebsite.com/images/website_log.png" />
</head>

<body>
<?php  
echo $postSubject.'<br>'.$postTextFormat; // contains content of forum post \\
?>
</body>
</html>
<?php
}
else
{
echo('You are a forum guest. Please sign in or register.');
}

?>

 

Please help if you can.

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.