Missing parameter "q" in bing image search API - bing

When I tried to use similar products search from Bing search api with the following url with a valid api key in the header, it returns an error saying the request is missing a parameter "q". I need to search the image without a query string but just the image URL.
https://api.cognitive.microsoft.com/bing/v7.0/images/search?modulesRequested=SimilarProducts&mkt=en-us&form=BCSPRD&imgUrl=https%3A%2F%2Fm.media-amazon.com%2Fimages%2FG%2F01%2Fzappos%2Flanding%2Fpages%2Fmensclothing%2FMelodyTest1%2FMensShoes1.V506596164.jpg&count=1
Thanks in advance

The endpoint is different. "Search" endpoint is meant for searching for images, given a query. "Details" endpoint will do the trick here. You need to do something like this:
GET https://api.cognitive.microsoft.com/bing/v7.0/images/details?imgurl=YOUR_IMAGE_URL&modules=SimilarImages
Use this with your access key as a header and it will work.

Related

How to use the keyword "location" in the URL parameter in AWS Amplify

I am currently working on a 1 page HTML app that uses URL parameters to do an API call. the URL parameters are set and used in QR codes so its necessary that they are able to change dynamically. A example URL would be something like app.com/index.html/?environment=demo&location=Kiosk
I currently have this app deployed in AWS Amplify, but I cant get other keywords to chain together. I have the following redirects in place:
These redirects make sure that every URL parameter I pass in the link works EXCEPT some keywords like the "location" keyword, next to some others. Using this keyword as a URL param gives a 502 server error, or if the redirects are not used an access denied error.
does anyone know how to get the location keyword to work? Thanks in advance!
You should be able to use a single rule that will forward everything to index.html EXCEPT urls with a "file extension" from the list below. That lets all your links work, but assets like images, fonts, code will pass through.
Doc for: Using Redirects - Single Page Apps
</^[^.]+$|\.(?!(css|gif|ico|jpg|js|png|txt|svg|woff|woff2|ttf|map|json)$)([^.]+$)/>

Azure API Manager - Issue on URL , working even if no sense url and just getting the last segment

We have found this bug in Api Manager that whenever you pass some similar words in the url its working properly even the url was not correct .
Example:
working url: {{Url}}/regulators
bad url but works with the same : {{Url}}/../auth/streams/../../regulators
Anybody encounter the same issue with your APIs?
Please see image below
Method GET is used to add form data to the URL in name or value pair. If you use GET, the length of URL will remain limited. It helps users to submit the bookmark the result. GET is better for the data which does not require any security or having images or word documents.
Also, this is used only to get the data from address bar in the browser.
We can check with below settings for API Responses:
Select the API you created in the previous step.
Select + Add Operation.
In the Frontend window, enter the following values.
Display Name(test call) : The name that is displayed in the developer portal.
URL(HTTP Verb) – GET : Select one of the predefined HTTP verbs.
URL (/test) : A URL path for API.
Description: Optional description of the operation, used to provide documentation in the developer portal to the developers using this API.
Select the Responses tab, located under the URL, Display name, and Description fields. Enter settings on this tab to define response status codes, content types, examples, and schemas.
Select + Add response, and select 200 OK from the list.
Under the Representations heading on the right, select + Add representation.
Enter application/json into the search box and select the application/json content type.
In the Sample text box, enter { "sampleField" : "test" }.
Select Save.
Refer to MS Docs to Monitor published API’s

Using Google Places Web API to search for business and using results to make a phone call

I'm working on a project, and I'm completely stuck.
I get the user's location using CLLocation and am able to get the place name using CLGeocoder, and using this I've constructed a URL to search the Google Places Web API.
My question is, how can I actually complete the search and return the top place result's phone number? Any help would be much appreciated!
let url: URL = URL(fileURLWithPath: "https://maps.googleapis.com/maps/api/place/textsearch/json?query=taxi+" + placeMark.locality!+"&key=" + self.GAPIKEY)
This is the URL I've come up in case that helps
The first thing you need to do is an HTTP GET on the URL to get the API results. Consult the following SO question for various ways to do that:
How to make an HTTP request in Swift?
The data returned will be a JSON document in the format described in the Google Places API Docs. Look for the formatted_phone_number and/or international_phone_number fields. See Working with JSON in Swift for how to parse the JSON string.

How can I find an URL of a Facebook page from its ID?

I know a Facebook page ID and I’d like to get a full URL to the page. The full URL looks like this:
http://www.facebook.com/pages/page-title/numeric-id
I don’t know the page-title. If I drop it from the URL and just use the numeric ID, I get a 404. I can call the Graph API to get the full URL from the ID, but that’s too heavy (one extra HTTP request, JSON parsing). Is there a better way?
I'm not fimiliar with Facebook Application but I know a bit about it. If you're talking about the page title, then there is a "name" object in your response code. Get that, and replace the white space with - and place your ID. May be, It will work
'http://www.facebook.com/pages/'.str_replace(' ','-',$name).'/numeric-id
// $name is your page name fetched from object.

What are the "base URLs" for status, photos, etc?

I developed an app that looks for specific terms using the facebook api (search).
Every result comes with an ID for the item that can be of many types like "status","photos",etc.
I remember that some time ago I could surf facebook and get this URLs from the browser address bar, but now with some updates that facebook has made it seems to be all AJAX based calls and it seems like you do not have a "specific page" for each item.
I looked over the web and could not find anything regarding this.
Is there any way I can get a "photo id" from the API and open it like "http://facebook.com/photos/0293820293842"?
Thanks for any clue.
https://graph.facebook.com/{id}/picture
https://graph.facebook.com/40796308305/picture (by page id)
https://graph.facebook.com/cocacola/picture (by page's name)
https://graph.facebook.com/4/picture (by user id)
https://graph.facebook.com/4/zuck (by user name)
after some time I just gave up trying to get the picture from the data provided by the search API.
From the api I get entries of type "photo" but they do not match with the API documentation found at http://developers.facebook.com/docs/reference/api/photo/ since I do not receive the fields "picture", "source" or "images" (they just does not exist in the results from a search)
Looking to find a way to use the approach of "setting up the URL from the fields received from the API" I could not get any sucess either.
That's one case... I set up a search for "pepsi"... and within the results I got a "photo" object.
In this object I have the following fields:
id: 100002307882828_188072634633218
author\id: 100002307882828
link : "http://www.facebook.com/photo.php?fbid=320417371337648&set=a.133681116677942.17717.131381520241235&type=1" (this link really points to the photo's page, but is not the photo itself)
object_id: 320417371337648
I used the URL you provided as a "base" and tried to setup some combination that returns me a photo but I always get "Content not found" as result.
The only way I could find the final photo URL is to make another call to the API using the Photo Id as parameter (but I would need to do a lot of calls to the API and this just do not fit my scenario)
If I call https://graph.facebook.com/320417371337648 I get everything I need from the photo, but this is the "another call" I would need to perform for each result I get.
Thanks a lot for your help,
Regards,
Victor Reboucas