gpt4 book ai didi

PHP/YQL/获取 : URL too long

转载 作者:可可西里 更新时间:2023-11-01 16:39:34 25 4
gpt4 key购买 nike

我在 PHP 中使用 YQL 和 file_get_contents 来发送查询。我使用 YQL 进行术语提取,因此我的查询包含大量文本。不幸的是,这会使 URL 过长并返回错误。如果我使用的文本量少得多,它就可以正常工作。

这是我可以在 YQL 上使用带有 GET 的 SELECT 语句的唯一方法吗?除了使用更少量的文本之外,我还有哪些其他选择?

最佳答案

Is the only way I can use a SELECT statement on YQL with GET, and what other options do I have besides using a smaller amount of text?

正如其他人所说,您可以使用 POST 请求而不是 GET。下面是一个将 file_get_contents() 与流上下文结合使用的示例。 cURL 或任何其他可以发出 POST 请求的远程内容获取代码也可以正常工作。

$ctx = stream_context_create(array('http' => array(
'method' => 'POST',
'header' => 'Content-Type: application/x-www-form-urlencoded',
'content' => http_build_query(array(
'context' => $my_really_really_huge_context,
'query' => $query,
'format' => 'json',
'q' => 'SELECT * FROM search.termextract WHERE context=@context and query=@query'
))
)));

$json = file_get_contents('http://query.yahooapis.com/v1/public/yql', false, $ctx);

关于PHP/YQL/获取 : URL too long,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4644553/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com