b0o / surfingkeys-conf

🏄 A SurfingKeys config which adds 180+ key mappings & 50+ search engines
MIT License
395 stars 67 forks source link

How to get Instagram...... search suggestions #5

Closed ghost closed 6 years ago

ghost commented 6 years ago

Can you tell me how to do it ?

addSearchAliasX('n', 'Instagram', 'https://www.instagram.com/', 's',
'https://www.instagram.com/web/search/topsearch/?context=blended&query=', function(response) {
    var res = JSON.parse(response.text);
    return res[1];
});

addSearchAliasX('m', 'google_maps search', 'https://www.google.com/maps/search/', 's','https://www.google.com/s?tbm=map&gs_ri=maps&suggest=p&authuser=0&hl=zh-CN&gl=ca&pb=&q=', function(response) {
    var res = JSON.parse(response.text);
    return res[1];
});
b0o commented 6 years ago

This question isn't directly related to this repository - it is probably better suited for StackOverflow or the main SurfingKeys repository - so I'm going to close this issue.

However, here are a few hints:

  1. The Instagram HTTP request should work, but you need to return data based on the parsed JSON response - the response from that endpoint seems to contain several arrays of objects, such as users, hashtags, places, and some other data. You need to extract the data you want and return it as a flat array of strings in the addSearchAliasX callback. You may want to use a REST toolkit like Postman or Insomnia to help understand HTTP responses. Take a look at some of the logic I use inside completions.js.

  2. Google doesn't allow cross-site HTTP requests for most of their main endpoints (excluding https://www.google.com/complete/search for autocompletion suggestions). You'll need to use something like the Google Places API to search Google Maps data.

Good luck.