Google custom search api returns 0 results when searchType is image - google-custom-search

I'm using Google Custom Search API to search for images. The search result is always 0 when I request for images. I'm following the documentation at the link below:
https://developers.google.com/custom-search/json-api/v1/reference/cse/list
according to the docs, by specifying searchType=images, the api only looks for images.
Here's what my url looks like:
https://www.googleapis.com/customsearch/v1?key=[API_Key]&cx=017576662512468239146:omuauf_lfve&searchType=image&q=cars
and the result looks like below:
{
"kind": "customsearch#search",
"url": {
"type": "application/json",
"template": "https://www.googleapis.com/customsearch/v1?q={searchTerms}&num={count?}&start={startIndex?}&lr={language?}&safe={safe?}&cx={cx?}&cref={cref?}&sort={sort?}&filter={filter?}&gl={gl?}&cr={cr?}&googlehost={googleHost?}&c2coff={disableCnTwTranslation?}&hq={hq?}&hl={hl?}&siteSearch={siteSearch?}&siteSearchFilter={siteSearchFilter?}&exactTerms={exactTerms?}&excludeTerms={excludeTerms?}&linkSite={linkSite?}&orTerms={orTerms?}&relatedSite={relatedSite?}&dateRestrict={dateRestrict?}&lowRange={lowRange?}&highRange={highRange?}&searchType={searchType}&fileType={fileType?}&rights={rights?}&imgSize={imgSize?}&imgType={imgType?}&imgColorType={imgColorType?}&imgDominantColor={imgDominantColor?}&alt=json"
},
"queries": {
"request": [
{
"title": "Google Custom Search - cars",
"totalResults": "0",
"searchTerms": "cars",
"count": 10,
"inputEncoding": "utf8",
"outputEncoding": "utf8",
"safe": "off",
"cx": "017576662512468239146:omuauf_lfve",
"searchType": "image"
}
]
},
"searchInformation": {
"searchTime": 0.049329,
"formattedSearchTime": "0.05",
"totalResults": "0",
"formattedTotalResults": "0"
}
}
If I remove searchType from the request, I get results back in the form of web pages. What is wrong here?

Your Custom Search Engine might have Image Search disabled. The CSE API returns 0 results if the searchType requested is disabled.
You can enable it by visiting https://cse.google.com/cse/all, opening your search engine, and switching the "Image Search" toggle to ON.

I'm 2 years delayed but i found the solution.
you need to go at your Custom Search Engine Dashboard and turn on the property "Search the entire Web" Or something like that.
When you get that property activated you must be able to see results

Related

Template message in whatsapp with static url

I am using whatsapp cloud api for messaging. I have created a template with a url button. In the template I have used a link to my app(Google play store). As per documentation,
https://developers.facebook.com/docs/whatsapp/on-premises/reference/messages#template-object
Developer provided suffix that will be appended to a previously created dynamic URL button.
I do not have any suffix as it is not a dynamic link. If I create a blank text parameter as sufix, Postman responds with error. How to create a url button without any suffix or please let me know if there is any other workaround for this issue. I do not want to add url directly into the body
{
"type": "button",
"sub_type": "url",
"index": "0",
"parameters": [
{
"type": "text",
"text": ""
}
]
}

Shopware 6 Admin Api - Updating existing record through patch method. Not working

shopware 6 admin api patch - why it's failing? I get error "Only single write operations are supported"
Following is api for rule-condition entity in the database, I update it with Id.
For same api get method is working!
url: api/rule-condition/dbb0d904c7c14860a9a94cf26b94eca6
method: patch
json body
[
{
"op": "replace",
"path": "/data/attributes/value/email",
"value": "test#gmail.com"
}
]
response:
{
"errors": [
{
"code": "0",
"status": "400",
"title": "Bad Request",
"detail": "Only single write operations are supported. Please send the entities one by one or use the /sync api endpoint.",
.......
I also tried changing json body to following
{
"data": {
"attributes": {
"value": {
"email": "test#gmail.com"
}
}
} }
Still it's not updating. Can somebody check and let me know what am i missing?
Documentation I followed:
https://shopware.stoplight.io/docs/admin-api/ZG9jOjEyMzA4NTQ5-writing-entities
This website has all apis and example methods. https://swagger.docs.fos.gg/,
rule-condition entity can also be found there.
Btw : I used postman for testing api
You're passing an array of objects in the request body, suggesting you want to update multiple records, but the endpoint only supports updating a single record. The correct payload in your case should look like this:
{
"value": {
"operator": "=",
"email": "test#gmail.com"
}
}
Notice that value is a json field and not only includes a single value. The exact content and the names of the properties of value depend on the type of condition used and usually it also includes the operator used in the condition.

Missing page content when using generator in Wikipedia API

I'm using the categorymembers generator in Wikipedia API to retrieve all pages in a category efficiently, for example:
https://en.wikipedia.org/w/api.php?action=query&format=json&prop=revisions&generator=categorymembers&rvprop=content&rvslots=*&gcmtitle=Category%3AAirports%20in%20Chad&gcmlimit=5000
(sandbox link)
But some articles are missing content, for instance page id 40376021 "Tchagen Airport":
"40376021": {
"pageid": 40376021,
"ns": 0,
"title": "Tchagen Airport"
},
However, when I retrieve the individual page, it does have content:
https://en.wikipedia.org/w/api.php?action=query&format=json&prop=revisions&titles=Tchagen%20Airport&formatversion=2&rvprop=content&rvslots=*
(sandbox link)
{
"batchcomplete": true,
"query": {
"pages": [
{
"pageid": 40376021,
"ns": 0,
"title": "Tchagen Airport",
"revisions": [
{
"slots": {
"main": {
"contentmodel": "wikitext",
"contentformat": "text/x-wiki",
"content": "page content here (long, ommited)"
}
}
}
]
}
]
}
}
I don't know what's going on here. It's not a recently created page so it can't be a caching issue. How to ensure that content for all pages can be seen in bulk results?
You only see the content of the first 50 pages.
Thus, it's best practice to set gcmlimit=50 in your request:
https://en.wikipedia.org/w/api.php?action=query&format=json&prop=revisions&generator=categorymembers&rvprop=content&rvslots=*&gcmtitle=Category%3AAirports%20in%20Chad&gcmlimit=50
In the response, you will see a continue>gcmcontinue value. Use this value in a next request to get the content of another 50 pages:
https://en.wikipedia.org/w/api.php?action=query&format=json&prop=revisions&generator=categorymembers&rvprop=content&rvslots=*&gcmtitle=Category%3AAirports%20in%20Chad&gcmlimit=50&gcmcontinue=page|482a402a042a3a4c48464c50011001dcc2dc0a|21079773
If the response does not contain a continue value, you know that you retrieved all data.

Wikipedia API requests for english page and spanish equivalent. Unable to retrieve spanish JSON for recentchanges

I'm attempting to use the wikipedia API. However, I'm finding that I can only retrieve recent changes for english pages. For example:
https://en.wikipedia.org/w/api.php?action=query&list=recentchanges&rctitle=Battle%20of%20Palma&format=json
returns:
{
"batchcomplete": "",
"query": {
"recentchanges": [{
"type": "edit",
"ns": 0,
"title": "Battle of Palma",
"pageid": 67226819,
"revid": 1061578435,
"old_revid": 1049512969,
"rcid": 1455128770,
"timestamp": "2021-12-22T15:19:02Z"
}]
}
}
However, the same request with the same page in Spanish returns an empty array:
https://en.wikipedia.org/w/api.php?action=query&list=recentchanges&rctitle=Batalla%20de%20Palma&format=json
{"batchcomplete":"","query":{"recentchanges":[]}}
Even though both of the pages exist:
English: https://en.wikipedia.org/wiki/Battle_of_Palma
Spanish: https://es.wikipedia.org/wiki/Batalla_de_Palma
I was using the incorrect API call. The above provides any changes across wikipedia. I needed to use the history call found here: https://www.mediawiki.org/wiki/API:REST_API/Reference#Get_page_history

Knowing if a Google Plus person has a real picture

I have an application that lists the users in your circles using the Google+ APIs. That works nicely except for one thing: the API does not say if a user has a picture or if the picture is just the placeholder (the blue silhouette).
https://developers.google.com/+/api/latest/people/list
{
"kind": "plus#person",
"etag": etag,
"id": string,
"displayName": string,
"image": {
"url": string
},
}
How do I determine if the picture is a placeholder? (so that I don't have to download it)
Image URLs are there:
https://www.google.com/s2/photos/profile/{user_id}
https://plus.google.com/s2/photos/profile/{user_id}
https://profiles.google.com/s2/photos/profile/{user_id}
For now, a 404 is better than downloading the default picture. I'd still love the API to simply tell us that the user has not set a picture :(
response will have isDefault: true for the placeholder image
"image": {
"url": "https://lh3.googleusercontent.com/.../photo.jpg?sz=50",
"isDefault": true
},