Error in Bing Search API - bing

I am using the new Bing Search API v.5 in my app (javascript).
This is the query: "31 'Jerry Willemse' netherlands 'intercop'"
If I access the Bing Search API from within my app I get zero results.
If I use the test tool available here: https://dev.cognitive.microsoft.com/docs/services/56b43eeccf5ff8098cef3807/operations/56b4447dcf5ff8098cef380d/console
I get several results.
The test tool should precisely mimic the behavior of the API.
This is the URL generated by the API test tool
https://api.cognitive.microsoft.com/bing/v5.0/search?q='jerry willemse' netherlands 'intercop' 31&count=10&offset=0&mkt=en-us&safesearch=Moderate
Can URLs include spaces?

In fact, urls cannot include spaces.
You can replace spaces with '%20' or '+'.
Here are some useful ones:
+   %2B   
space %20 
/   %2F     
?   %3F     
%  %25     
#   %23     
&   %26     
=   %3D
You can also use function encodeURI(URIstring) provided by javascript to do replacing.

Related

Extracting value from API/Webpage

I'm trying to retrieve the 'estimated value' field displayed on the https://www.poppriceguide.com/ website so it can be displayed in a google sheets automatically.
Example URL: https://www.hobbydb.com/marketplaces/poppriceguide/catalog_items/iron-man-model-39
I've tried using the =IMPORTXML() function as such:
=IMPORTXML(https://www.hobbydb.com/marketplaces/poppriceguide/catalog_items/iron-man-model-39, /*[contains(concat( " ", #class, " " ), concat( " ", "value", " " ))])
with no success, seemingly to be caused because it is retrieved using Javascript.
Doing some research I found poppriceguide is using Hobbydb's API which according to Hobbydb should be available.
https://help.hobbydb.com/support/solutions/articles/36000265069-access-to-the-hobbydb-api
https://help.hobbydb.com/support/solutions/articles/36000263216-adding-estimated-values-and-other-data-to-your-own-site
Going through the network calls I found this API request, however when I do it separately it gives me an authentication failed.
https://www.hobbydb.com/api/price_guide?catalog_item_id=520170
Other API Requests do work however, for example:
https://www.hobbydb.com/api/catalog_items/323645
How would I go about retrieving the value so it can dynamically be displayed in a Google sheets?
The link you shared says
Let us know if you are interested in exploring co-operation and using the API. Please provide us with a good overview of your project.
This is likely to mean that the API requires authentication
It is also possible for the API to have certain endpoints that are free, which is why some seem to work. Yet with no publicly available documentation, there is no way to know which ones.
So unfortunately you will not be able to use Apps Script for this, you could look into some other web scraping software, maybe Puppeteer. Or try and apply for an API key from HobbyDB.

How to escape asterisk character from Easy Redmine rest API Call

I want to escape asterisk(*) character from easy Redmine rest API URL.
I am trying to get the result based on given URL.
https://moksh.easyredmine.com/issues.xml?limit=100&tracker_id=4&project_id=109&subject=*ALERT* Sophos XG Firewall - Gateway status alert&sort=updated_on:desc
I want only those easy redmine issues where query string matches with api issue response.
But it is selecting all records and it is not filtering based on project and subject. I think asterisk is creating the problem. I am using PowerShell and POSTMAN to call the API.
Any help would be appreciated.
According to the documentation, the parameters sort, offset, limit and page are required.
You're not using offset and page.
You can switch to console on the documentation, and build an example with your value, which -using your values- leads to http://moksh.easyredmine.com/issues.xml?sort=updated_on%3Adesc%20&offset=0&limit=100&page=&tracker_id=4&project_id=109&subject=*ALERT*%20Sophos%20XG%20Firewall%20-%20Gateway%20status%20alert

Unable to get ad preview using facebook graph api?

Using the information from this documentation to generate iframe of the ad preview (in Facebook Graph API),
According to the documentation, we need to use the following URL
https://graph.facebook.com/v2.8/{adgroup-id}/previews/ad_format=
Not able to understand how to pass in the ad_format. It is compulsory to pass this parameter.
GET parameters are passed like:
https://graph.facebook.com/v2.8/{adgroup-id}/previews/?ad_format=DESKTOP_FEED_STANDARD
This question is old. But in order to run a preview you need to pass two parameters:
ad_format
There are various types of ad_formats: You generally use them according to your specific use. For basic mobile and desktop testing
DESKTOP_FEED_STANDARD, MOBILE_FEED_BASIC, MOBILE_FEED_STANDARD, MOBILE_FULLWIDTH will work fine
access_token
So your URL will be of the format :
https://graph.facebook.com/v4.0/AD_ID/previews?access_token=ACCESS_TOKEN&ad_format=DESKTOP_FEED_STANDARD

Google Search autocomplete API?

Does Google provide API access to autocomplete for search like on the actual site? I have not been able to find anything.
I would like to use Google's autocomplete logic for web search on my own site which relies on Google's search API.
The new url is:
http://suggestqueries.google.com/complete/search?client=firefox&q=YOURQUERY
the client part is required; I did't test other clients.
[EDIT]
If you want the callback use this:
http://suggestqueries.google.com/complete/search?client=chrome&q=YOURQUERY&callback=callback
As #Quandary found out; the callback does not work with client "firefox".
[EDIT2]
As indicated by # user2067021 this api will stop working as of 10-08-2015: Update on the Autocomplete API
First, go to google, click Settings (bottom right corner), change Search Settings to "never show instant results. That way, you'll get regular autocomplete instead of a full page of instant results.
After your settings are saved, go back to the Google main home page. Open your browser's developer tools and go to the Network tab. If you're in Firefox, you might have to reload the page.
Type a letter in the search box. A new line should appear in the Network window you just opened. That line is showing where the autocomplete data came from. Copy that url. It should look something like this:
https://www.google.com/complete/search?client=hp&hl=en&sugexp=msedr&gs_rn=62&gs_ri=hp&cp=1&gs_id=9c&q=a&xhr=t&callback=hello
You'll notice your search term right after the part that says q=.
Add &callback=myAmazingFunction to the end of the url. You may replace myAmazingFunction with whatever you want to name your function that will handle the data.
Here's an example of the code required to show the autocomplete data for the search term "a".
<div id="output"></div>
<script>
/* this function shows the raw data */
function myAmazingFunction(data){
document.getElementById('output').innerHTML = data;
}
</script>
<script src="https://www.google.com/complete/search?client=hp&hl=en&sugexp=msedr&gs_rn=62&gs_ri=hp&cp=1&gs_id=9c&q=a&xhr=t&callback=hello&callback=myAmazingFunction"></script>
Now that you know how to get the data, the next step is to automatically change that last script (the one with the autocomplete url). The basic procedure is: each time the user types something in the search box (onkeyup) replace the search term (q=whatever) in the url, and then append to the body a script with that url. Remove the previous script so that the body doesn't get cluttered.
For more info, see http://simplestepscode.com/autocomplete-data-tutorial/
Most of the above mentioned methods works for me, specifically the following serves my purpose.
http://suggestqueries.google.com/complete/search?client=firefox&q=YOURQUERY
Being a newbie in web programming, I'm not much aware of the "Callback" functionality and the format of the file returned by query. I'm little aware of AJAX and JSON.
Could someone provide more details about the format of file returned by the query.
Thanks.
Hi I don't know if this answer is relevant for you anymore or not but google returns JSON data through following get request (although this isn't an official API but many toolbars are using this API so there's no reason why google might discontinue it):
http://google.com/complete/search?q=<Your keywords here>&hl=en
You should use AutocompleteService and pass that text box value into the service.getPlacePredictions function. It send the data in callback function.
let service = new google.maps.places.AutocompleteService();
let displaySuggestions = function(predictions, status) {
}
service.getPlacePredictions({
input: value
}, displaySuggestions);
Base: https://developers.google.com/maps/documentation/javascript/reference/places-autocomplete-service#AutocompleteService.getPlacePredictions
example: https://dzone.com/articles/implement-and-optimize-autocomplete-with-google-pl
I'm using (( Edrra.com )) API that have google search and suggestions that works with both GET & POST:
Google suggestions:
https://edrra.com/v1/api.php?c=google&f=suggest&k=YOUR_API_KEY&v=YOUR_SEARCH
Google search:
https://edrra.com/v1/api.php?c=google&f=search&k=YOUR_API_KEY&v=YOUR_SEARCH
and more...
What are you trying to use an auto-complete for? More information would help narrow it down.
As far as I know, google does not provide one, but they do exist like jQuery UI's auto-complete.
EDIT:
If you are using their custom search API view here for autocomplete.

Facebook graph api search results depends on location?

I've tried to fetch results using Graph search API and I've notice that the results when executed in my computer (Argentina) are different from the results when I run it in a server (France).
Is this like this? How can I force a location for a search?
Thanks #Sascha Galley. I also find another easy way.
Just add &locale=en_US in Facebook Graph search API query URL.
This is languages and locales list refrence
I don't know exactly which results are different and which skd version you are using, but one possible approach is to send the accept-language header with the cURL request. In the facebook api php file add the following line in the function makeRequest() below $opts = self::$CURL_OPTS;
$opts[CURLOPT_HTTPHEADER] = array('Accept-Language: en-us,en;');
This post is almost two years old: Get Facebook Graph API results in English
Actually, this issue should have already been solved: Return values from the graph-api depend on geographic server location