我有一個在線項目「一週的問題」;這個項目允許用戶提交他們的問題。這些問題保存在一個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