WHen我在WAMP上从cmd.exe命令行运行这个脚本,我得到:
Could not retrieve data from OpenAmplify.file_get_contents(http://portal
tnx.openamplify.com/AmplifyWeb/AmplifyThis?apiKey=MY_API_KEY_GOES_HERE): failed to open stream: HTTP request failed! (C:\wamp\www\Learning_Query_Pa
th\src\QueryPath\QueryPath.php: 4053)当我通过firefox浏览器v19.0从localhost运行这个脚本时,我得到:
Fatal error: Maximum execution time of 30 seconds exceeded in C:\wamp\www\Learning_Query_Path\src\QueryPath\QueryPath.php on line 4525下面是我使用的脚本:
<?php
require 'src/QueryPath/QueryPath.php';
$url = 'http://portaltnx.openamplify.com/AmplifyWeb/AmplifyThis?';
$key = 'I_PUT_MY_API_KEY_HERE';
$text = 'I_PUT_TEXT_HERE';
$params = array(
'apiKey' => $key,
);
$url .= http_build_query($params);
$options = array(
'http' => array(
'method' => 'POST',
'user_agent' => 'QueryPath/2.0',
'header' => 'Content-type: application/x-www-form-url-encoded',
'content' => http_build_query(array('inputText' => $text)),
),
);
$context = stream_context_create($options);
try {
$qp = qp($url, NULL, array('context' => $context));
}
catch (Exception $e) {
print "Could not retrieve data from OpenAmplify." . $e->getMessage();
exit;
}
$qp->find('ProperNouns>TopicResult>Topic>Name')->slice(0, 20);
$out = qp(QueryPath::HTML_STUB, 'body')->append('<ul/>')->find('ul');
foreach ($qp as $name) {
$out->append('<li>' . $name->text() . '</li>');
}
$out->writeHTML();
?>我怎么才能让它工作呢?
附注: Open Amplify是一个web服务,它接受所提供的文本,并在分析它之后,返回关于它的许多有趣的事情。我真的很热衷于让这项工作成为QueryPath的忠实粉丝,所以我只对如何让它与QueryPath一起工作的建议感兴趣!
发布于 2013-02-25 23:33:21
尝试点击此url。这应该可以工作,http://portaltnx20.openamplify.com/AmplifyWeb_v21/AmplifyThis
https://stackoverflow.com/questions/15044375
复制相似问题