谷歌自定义搜索API卷曲的麻烦 [英] Google Custom Search API curl trouble

查看:135
本文介绍了谷歌自定义搜索API卷曲的麻烦的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在计算器一个新手,所以请耐心与我:)

我试图获得与谷歌自定义搜索API访问。
但我得到返回我无法理解。

我的查询是这样的:

<$p$p><$c$c>https://www.googleapis.com/customsearch/v1?&key=********&q=red%2Bsox&cx=**********&start=0&num=10&cr=countryCA&lr=lang_fr&client=google-csbe&output=xml_no_dtd

和结果我得到的是这样?

 字符串{错误:{错误:[{域:全局,理:无效的,消息:无效值 }],code:400,消息:无效值}}'(长度= 172)

我是什么做错了吗?
我想从谷歌的结果出现。

在此先感谢:)


解决方案

您没有CX。
看看这个回答
什么情况是,因为这个API主要用于增加一个搜索选项
为您的网站,你必须指定自定义搜索引擎(例如只搜索您的网站)。
当你想通过这个code在网络上搜索你需要做以上。添加假
网站(在那里你会增加你的搜索文本框),配置(在网络上搜索,或者你的网站,或者其他),然后删除该假冒网站

更新

哦,上帝,我只是看到了。抱歉。那么问题是,你从0开始有效的做法是1.更改启动= 0开始= 1,我想你会好到哪里去。看看这为启动参数官方网页有效值

I'm a newbie at stackoverflow so please be patient with me :)

I'm trying to get access with the Google Custom Search API. But I get return that I can't understand.

My query is like this:

https://www.googleapis.com/customsearch/v1?&key=********&q=red%2Bsox&cx=**********&start=0&num=10&cr=countryCA&lr=lang_fr&client=google-csbe&output=xml_no_dtd

And the result I get is this?

string '{"error": {"errors": [{"domain": "global","reason": "invalid","message": "Invalid Value"}],"code": 400,"message": "Invalid Value"}}' (length=172)

What am I doing wrong? I want the result from Google to appear.

Thanks in advance :)

解决方案

You don't have a cx. Take a look at this answer What happens is because this api is used mostly for adding a search option for your site you have to specify you custom search engine (e.g. search only your site). When you want this to search the web by code you need to do the above. Add a fake site (where you would add your search textbox), configure it (search the web, or your site, or whatever else) and then delete the fake site

Update

Oh god, i just saw that. Sorry. Well the problem is that you start with 0. Valid is 1. Change start=0 with start=1 and i think you would be good to go. Take a look at this for valid values for the start parameter official page

这篇关于谷歌自定义搜索API卷曲的麻烦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆