我有一个在线项目“一周的问题”;这个项目允许用户提交他们的问题。这些问题保存在一个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”
请建议我该怎么做。我怎么能从这个URL获取这个“t = 24”。
当我调用simplepost.php时,会使用posts.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页。
你如何提交simplepost.php? – seth 2009-07-24 19:39:22