我使用以下代码向boilerpipe java web api发送get请求以将html内容提取到网站的纯文本中,我使用telerivet webhook api向我的php文件所在的服务器发送和接收消息,提供的超时是10秒,我总是使用此代码超时,请帮助我
if ($_POST['secret'] !== $webhook_secret)
{
header('HTTP/1.1 403 Forbidden');
echo "Invalid webhook secret";
}
else
{
if ($_POST['event'] == 'incoming_message')
{
$content = $_POST['content'];
$from_number = $_POST['from_number'];
$phone_id = $_POST['phone_id'];
// do something with the message, e.g. send an autoreply
header("Content-Type: application/json");
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL,
'http://boilerpipe-web.appspot.com/extract?url=http://www.kvgengg.com&extractor=DefaultExtractor&output=text&extractImages='
));
$content = curl_exec($ch);
echo $content;
}
}
答案 0 :(得分:1)
似乎存在语法错误,因为您在网址中有一个额外的括号,我已将其删除。
如果您使用http_build_query
传递参数,那么它应该可以解决您的问题
if ($_POST['secret'] !== $webhook_secret)
{
header('HTTP/1.1 403 Forbidden');
echo "Invalid webhook secret";
}
else
{
if ($_POST['event'] == 'incoming_message')
{
$content = $_POST['content'];
$from_number = $_POST['from_number'];
$phone_id = $_POST['phone_id'];
// do something with the message, e.g. send an autoreply
header("Content-Type: application/json");
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL,
'http://boilerpipe-web.appspot.com/extract?' .
http_build_query(array(
'url' => 'http://www.kvgengg.com',
'extractor' => 'DefaultExtractor'
'output' => 'text',
'extractImages' => ''
))
);
$content = curl_exec($ch);
echo $content;
}
}