我开始使用AlchemyAPI键从url中提取json/xml数据。使用PHP通过无法将提取的数据从API显示为HTML格式
<form method="post" class="SearchCSS" action="/NENSearch.php?go" id="categorizer">
<h1>Enter your Queries</h1>
<input type="text" name="Search" placeholder="Enter the article URL">
<input type="submit" value="Search">
</form>
则:如果随着查询网址进入,但我想要的URL部分来自用户侧所以首先我创建了下面的代码形式炼丹URL API密钥的工作好了用户提交的URL到炼丹API的端点和存储JSON数据到一个变量,然后再使用下面的代码(问题:代码实际上没有任何显示):显示所分析的数据
<?php
echo "this works here";
if(isset($_POST['submit'])){
if(isset($_GET['go'])){
if(preg_match("%^((http?://)|(www\.))([a-z0-9-].?)+(:[0-9]+)?(/.*)?$%i", $_POST['Search'])){
$url=$_POST['Search'];}
echo $url;}
$response = file_get_contents("http://gateway-a.watsonplatform.net/calls/url/URLGetCombinedData?extract=page-image,entity,keyword,taxonomy&apikey=1f324507a9d516d9429e14f970ccc83de9df2&showSourceText=1&sentiment=1&outputMode=json"ations=1&url='.$url.'");
$response = json_decode($response);
echo $response;}
echo "<br/> this is not working";
?>
基本alchemyAPI我使用的网址看起来像这样(在末尾添加了drupal url): http://access.alchemyapi.com/calls/url/URLGetRankedTaxonomy?apikey=1f324507a9d51694a29e14f970ccc83de9df2&outputMode=jsonp&knowledgeGraph=1&extract=taxonomy&url=https://www.drupal.org/node/2148541
我刚开始使用API的,任何帮助将解析的json数据显示为html格式都会有很大的帮助。提前致谢。 :)