我有来自数据提取工具/网站 ( http://import.io ) 的PHP API 代码块,格式如下。我想要一个搜索框,它返回的结果不是一个,而是多个这些“连接器”代码块(它们被称为连接器,因为它们将您的搜索查询与通过 import.io 管道传输的结果连接起来,大概)。
我是 PHP 的菜鸟,所以我不知道该怎么做。
<?php
$userGuid = "kjnjkn-32d2-4b1c-a9c5-erferferferferf";
$apiKey = "APIKEY";
function query($connectorGuid, $input, $userGuid, $apiKey) {
$url = "https://api.import.io/store/connector/" . $connectorGuid . "/_query?_user=" . urlencode($userGuid) . "&_apikey=" . urlencode($apiKey);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(array("input" => $input)));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
$result = curl_exec($ch);
curl_close($ch);
return json_decode($result);
}
// Query for tile WEBSEARCH
$result = query("98c9bac2-e623-4e31-8a3e-erferferferf", array(
"search_query" => "term1",
), $userGuid, $apiKey);
var_dump($result);
// Query for tile WEBSEARCH
$result = query("98c9bac2-e623-4e31-8a3e-bferfreferfe", array(
"search_query" => "term2",
), $userGuid, $apiKey);
var_dump($result);