Javascript 共享页面的链接
我正在从用户档案中共享一个事件的链接,事件页面是动态的,当用户单击共享到Facebook时,我获取事件ID并将其存储到会话变量,我在事件页面中使用此会话变量来描述:og标记。但是my:og标记没有显示数据。 这是我的密码:Javascript 共享页面的链接,javascript,php,facebook,facebook-graph-api,facebook-sdk-4.0,Javascript,Php,Facebook,Facebook Graph Api,Facebook Sdk 4.0,我正在从用户档案中共享一个事件的链接,事件页面是动态的,当用户单击共享到Facebook时,我获取事件ID并将其存储到会话变量,我在事件页面中使用此会话变量来描述:og标记。但是my:og标记没有显示数据。 这是我的密码: function post(id) { document.cookie = "eventID = "+id; <?php $_SESSION['EVENT_ID'] = $_COOKIE['eventID'];
function post(id) {
document.cookie = "eventID = "+id;
<?php $_SESSION['EVENT_ID'] = $_COOKIE['eventID']; ?>;
FB.ui({
method: 'share',
href: "mywebsiteURL/events.php"
}
}
//Here is the head of my events.php
$col = 'events.*,status.name as statusName,mosque_reg.name as mosque';
$table = "events,status,mosque_reg";
$where = "events.id = '".$obj->verifyint($_SESSION['EVENT_ID'])."' AND events.status_id = status.id
AND events.inserted_by = mosque_reg.inserted_by";
$ticket = $obj->read_specific_event($col,$table,$where);
if($ticket->num_rows>0)
{
$issue = $ticket->fetch_assoc();
$pic ="https://www.theglobalmuslim.com/mosque/portal/images/events/".$issue['photo'];
$contactName = $issue['contactPerson'];
$contact = $issue['contactNumber'];
$description = $issue['description'];
$topic = $issue['topic'];
}
?>
<meta property="fb:app_id" content="258374655358948" />
<meta property="og:site_name" content="The Global Muslim"/>
<link property="og:url" content="https://www.theglobalmuslim.com/events.php?id=<?php echo
$_SESSION['EVENT_ID']; ?>"/>
<meta property="og:type" content="website" />
<meta property="og:title" content="Event Name:<?php echo $topic; ?>" />
<meta property="og:description" content="New event is held at Mosque <?php echo
$issue['mosque']."\n."." Description: ".$description ?>" />
<meta property="og:image" content="<?php echo $pic; ?>" />
功能岗(id){
document.cookie=“eventID=”+id;
;
FB.ui({
方法:'共享',
href:“mywebsiteURL/events.php”
}
}
//这是myevents.php的标题
$col='events.*,status.name作为statusName,mosque_reg.name作为mosque';
$table=“事件、状态、清真寺登记”;
$where=“events.id=””$obj->verifyint($\u SESSION['EVENT\u id'])。“”和events.status\u id=status.id
和events.inserted_by=清真寺_reg.inserted_by”;
$ticket=$obj->read_-specific_事件($col,$table,$where);
如果($ticket->num_rows>0)
{
$issue=$ticket->fetch_assoc();
$pic=”https://www.theglobalmuslim.com/mosque/portal/images/events/“$发行[‘照片’];
$contactName=$issue['contactPerson'];
$contact=$issue['contactNumber'];
$description=$issue['description'];
$topic=$issue['topic'];
}
?>
我通过打开内部页面的URL解决了这个问题,我使用GET方法在:og标记中显示事件信息。向代码泼圣水您是否使用了会话_start()
?是的,在我的连接文件中,会话变量工作正常。“会话变量工作正常”-不,不是。它对您来说工作正常,因为您的浏览器在cookie中存储了会话ID。当Facebook scraper请求您的URL获取元数据时,它没有该会话ID。因此PHP将启动一个新的空会话,因为此请求没有传递会话ID。会话对于您想要的内容是错误的首先,你需要在共享URL本身中传递你需要传递的任何信息。请在将来努力使你的代码更具可读性。仅此一点就可以帮助你解决许多错误。