简体   繁体   中英

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. 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.

I am new to gnip, but I understand I can use the search api.

I'm having trouble finding a Java simple tutorial/'hello world' example for making gnip queries using rest :(

I found the rule 'url_contains' here:: http://support.gnip.com/apis/search_api/rules.html

And example REST requests here: https://github.com/gnip/support/tree/master/Search%20API/Java

But nothing specifically on how to apply a gnip rule to a rest request.

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 ::

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::

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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