简体   繁体   English

如何使用REST请求进行gnip查询(Java)

[英]How do I make a gnip query using a REST request (Java)

I have a domain name enrichment task. 我有一个域名充实任务。 I want to make a make a GNIP query using REST. 我想使用REST进行GNIP查询。 Here's what I want to do: 这是我想做的:

Make a query to gnip containing a shortened url eg/"http ow.ly4eyW50fy4eP Then use a gnip rule (maybe 'url_contains') to get the expanded url. 对包含缩短的URL的gnip进行查询,例如“ /” http ow.ly4eyW50fy4eP,然后使用gnip规则(可能是“ url_contains”)来获取扩展的URL。

I am new to gnip, but I understand I can use the search api. 我是gnip的新手,但我知道我可以使用搜索api。

I'm having trouble finding a Java simple tutorial/'hello world' example for making gnip queries using rest :( 我在查找Java简单教程/'hello world'示例中遇到麻烦,可以使用rest :(

I found the rule 'url_contains' here:: http://support.gnip.com/apis/search_api/rules.html 我在这里找到了规则“ url_contains”: http : //support.gnip.com/apis/search_api/rules.html

And example REST requests here: https://github.com/gnip/support/tree/master/Search%20API/Java 此处还有示例REST请求: https : //github.com/gnip/support/tree/master/Search%20API/Java

But nothing specifically on how to apply a gnip rule to a rest request. 但是,没有任何关于如何将gnip规则应用于休息请求的专门内容。

I'm guessing the query might look like this (curl). 我猜查询可能看起来像这样(卷曲)。

curl -X POST -u <me>   
"https://search.gnip.com/accounts/me/search/prod.json -d '{
"rules": [
  {
    "value": "url_contains:bla"
  }
 ]
}'

So my first question is, does this request look ok? 所以我的第一个问题是,这个请求看起来还可以吗?

And if not, could anybody help me with an example? 如果没有,有人可以帮我举个例子吗? Or perhaps signpost me to an example online? 还是在网上给我举个例子?

Ah! 啊! The answer is in the PostRequest.java class here :: 答案是在PostRequest.java类中的::

https://github.com/gnip/support/tree/master/Search%20API/Java https://github.com/gnip/support/tree/master/Search%20API/Java

and no rule is required, the shortened url simply needs to be present in the payload as shown here:: 并且不需要任何规则,缩短的URL仅需要出现在有效负载中,如下所示:

http://support.gnip.com/enrichments/expanded_urls.html http://support.gnip.com/enrichments/expanded_urls.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM