我有一个在线项目“本周问题”;这个项目允许用户提交他们的问题。这些问题保存在一个mysql表中;问题也被发送到另一个simplepost.php,该文件将问题存储在phpBB 中。我想对每个问题都使用这个 phpBB 来讨论这个问题。
所以现在,我的项目将问题存储在 sql 表中,并在 phpBB 中发布问题。
但是当问题发布在 phpBB 中时,它会存储在“ http://servername.com/phpBB3/viewtopic.php?f=5&t=24 ”中,其中 t=24 是问题。
我想以某种方式获取这个 url 并提取 t=24,这样我就可以为我的项目中的每个问题提供一个可点击的链接,以指导其特定 phpBB 页面的问题。
假设我的项目在:http ://servername.com/qotw/profile.html (这允许用户发布问题并将问题插入到 sql 表中,并在 phpBB/simplepost.php 中调用将问题发布到phpBB)
可以在 php 中看到这个问题:“ http://servername.com/phpBB3/viewtopic.php?f=5&t=24 ”
请向我建议我该怎么做。我怎样才能从这个网址中获取这个“t = 24”。
当我的 simplepost.php 被调用时,是使用 posting.php 发布问题并返回一个返回值。
simplepost.php 中的代码如下所示:
$title = "This is the title of the message.";
//$body = "This is the message body.";
$post_fields = array(
'subject' => $title,
'addbbcode20' => 100,
'message' => $body,
'lastclick' => $lclick[0],
'post' => 'Submit',
'attach_sig' => 'on',
'creation_time' => $lclick[0],
'form_token' => $security123[1],
'filecomment' => '',
);
//Wait (you might also do this by setting lastclick in the past by 3 seconds
sleep(3);
//Set up curl session for posting the message
$ch1 = curl_init();
curl_setopt($ch1, CURLOPT_URL,$purl);
curl_setopt($ch1, CURLOPT_POST, true);
curl_setopt($ch1, CURLOPT_POSTFIELDS, $post_fields);
curl_setopt($ch1, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch1, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch1, CURLOPT_HEADER, false );
curl_setopt($ch1, CURLOPT_COOKIE,'cookie.txt');
curl_setopt($ch1, CURLOPT_COOKIEJAR,'cookie.txt');
curl_setopt($ch1, CURLOPT_COOKIEFILE,'cookie.txt');
$result2= curl_exec ($ch1);
//$result3= curl_exec ($ch1, CURLOPT_URL,$purl);
curl_close ($ch1);
echo $result2;
响应来自 $result2。页面转到http://servername.com/phpBB3/viewtopic.php?f=5&t=24 ”。
但问题是这一切都发生在后端。我的项目没有显示 phpBB 的 viewtopic.php 页面。