Google Cloud Vision API fails to access Image URLs until 1PM PST - google-cloud-platform

I am working with google cloud vision API safe search function. I am calling the API by passing in the URLs to remote images.
I noticed that the same image URL fails before 1PM PST, where it works after roughly 1PM. I have been noticing this pattern for 3 day.
Failing messages (Before 1PM) look something like this:
"error": {
"code": 14,
"message": "We can not access the URL currently. Please download the content and pass it in."
}
where as when it works correctly (after 1PM), I can get expected responses like this:
"adult": "UNLIKELY",
"spoof": "UNLIKELY",
"medical": "UNLIKELY",
"violence": "UNLIKELY",
"racy": "LIKELY"
}
Has anyone else experienced a similar issue? I am still on free plan, not sure if that is a problem.
Edit: Adding response -
{
"responses": [
{
"error": {
"code": 14,
"message": "We can not access the URL currently. Please download the content and pass it in."
}
},
{
"error": {
"code": 4,
"message": "We can not access the URL currently. Please download the content and pass it in."
}
},
{
"error": {
"code": 14,
"message": "We can not access the URL currently. Please download the content and pass it in."
}
},
{
"safeSearchAnnotation": {
"adult": "LIKELY",
"spoof": "VERY_UNLIKELY",
"medical": "UNLIKELY",
"violence": "UNLIKELY",
"racy": "VERY_LIKELY"
}
},
{
"error": {
"code": 4,
"message": "We can not access the URL currently. Please download the content and pass it in."
}
},
{
"safeSearchAnnotation": {
"adult": "UNLIKELY",
"spoof": "VERY_UNLIKELY",
"medical": "UNLIKELY",
"violence": "VERY_UNLIKELY",
"racy": "VERY_LIKELY"
}
},
{
"error": {
"code": 14,
"message": "We can not access the URL currently. Please download the content and pass it in."
}
},
{
"error": {
"code": 14,
"message": "We can not access the URL currently. Please download the content and pass it in."
}
},
{
"error": {
"code": 4,
"message": "We can not access the URL currently. Please download the content and pass it in."
}
},
{
"safeSearchAnnotation": {
"adult": "VERY_UNLIKELY",
"spoof": "VERY_UNLIKELY",
"medical": "VERY_UNLIKELY",
"violence": "VERY_UNLIKELY",
"racy": "POSSIBLE"
}
},
{
"safeSearchAnnotation": {
"adult": "POSSIBLE",
"spoof": "VERY_LIKELY",
"medical": "UNLIKELY",
"violence": "UNLIKELY",
"racy": "VERY_LIKELY"
}
},
{
"error": {
"code": 4,
"message": "We can not access the URL currently. Please download the content and pass it in."
}
},
{
"safeSearchAnnotation": {
"adult": "UNLIKELY",
"spoof": "LIKELY",
"medical": "UNLIKELY",
"violence": "UNLIKELY",
"racy": "POSSIBLE"
}
},
{
"safeSearchAnnotation": {
"adult": "POSSIBLE",
"spoof": "POSSIBLE",
"medical": "VERY_UNLIKELY",
"violence": "UNLIKELY",
"racy": "VERY_LIKELY"
}
},
{
"error": {
"code": 4,
"message": "We can not access the URL currently. Please download the content and pass it in."
}
},
{
"error": {
"code": 14,
"message": "We can not access the URL currently. Please download the content and pass it in."
}
}
]
}
200 OK

If you are using publicly available URLs you will encounter this error from time to time since there is no guarantee that the image is readily available. The host of the image might deny some request for DOS prevention. See imageUri reference for more details.
imageUri
The URI of the source image. Can be either:
A Google Cloud Storage URI of the form gs://bucket_name/object_name.
Object versioning is not supported. See Google Cloud Storage Request
URIs for more info.
A publicly-accessible image HTTP/HTTPS URL. When fetching images from
HTTP/HTTPS URLs, Google cannot guarantee that the request will be
completed. Your request may fail if the specified host denies the
request (e.g. due to request throttling or DOS prevention), or if
Google throttles requests to the site for abuse prevention. You should
not depend on externally-hosted images for production applications.
When both gcsImageUri and imageUri are specified, imageUri takes
precedence.
What I could suggest is to download the image locally or put it in cloud storage and from there you can use it as input.

Related

how to create schedule live with facebook live api?

I can not create a schedule live broadcast with live api.
this is my request:
https://graph.facebook.com/{page_id}/live_videos
{
"event_params":{
"start_time":1670053893,
"cover":"https://my-domain/product_system_back/product_img/2ad1e2baee4e4e2f8eb4.jpg"
},
"title":"freferfge",
"description":"ewferferfer",
"access_token":"my token",
"status":"SCHEDULED_LIVE",
"published":false
}
but i got the response:
{
"error": {
"message": "(#100) You need to set a planned start time for a scheduled broadcast",
"type": "OAuthException",
"code": 100,
"fbtrace_id": "AqvtD5W1wJSrpy30V0aigGR"
}
}
Is anything wrong?

Getting an error from Facebook Server-Side API when sending a pixel event

I am trying to make use of Facebook Server-Side API to send pixel events from my server. I'm making a POST request to this endpoint:
https://graph.facebook.com/v6.0/509380299968653/events?access_token=<SYSTEM_USER_ACCESS_TOKEN>
and sending this payload:
data:[
{
"event_name": "PageView",
"event_time": 1586978506,
"user_data": {
"fbc": "fb.1.1554763741205.AbCdEfGhIjKlMnOpQrStUvWxYz1234567890",
"fbp": "fb.1.1558571054389.1098115397"
}
}
]
,
"test_event_code":"TEST13699"
However, I'm getting an error response from the facebook server:
{
"error": {
"message": "(#100) Tried accessing nonexisting field (events) on node type (AdsPixel)",
"type": "OAuthException",
"code": 100,
"fbtrace_id": "AaqSg_DnGvvpjI3cWCK1yPU"
}
}
Need help to figure out what I'm doing wrong.

MPGS (mastercard): How to tokenize a transaction (how to create token)?

I'm trying to create token with MPGS.
I'm following this guide:
https://sample-sub.domain.mastercard.com/api/documentation/integrationGuidelines/supportedFeatures/pickAdditionalFunctionality/tokenization/tokenization.html?locale=en_US#x_tokenConfiguration
In the section "Token Operations" > "Tokenize", it says:
You can use this operation to create or update a token by storing
payment details against the token. ...
I'm posting this to help people who are frustrating like me with MPGS. I faced series of issues, and pulled my hair off many times. So here's the issues I faced and how to solve them (I'm stuck with issue #4).
Issue #1: Invalid credentials.
Fix: Make sure you're hitting the correct URL.
https://example-subdomain.mastercard.com/..
https://some.other-example.mastercard.com/..
https://MILLION-OTHER-POSSIBILITIES.mastercard.com/..
Even the documentation guide link have these same sub-domains, so make sure you're hitting the correct URL, and make sure you're following the correct documentation link.
Issue #2: Invalid parameters, or server asking for parameters although you've provided them.
Fix: If using Postman, make sure you set the parameters in "Body" > "raw" as JSON, like so:
{
"sourceOfFunds": {
"provided": {
"card": {
"expiry": {
"month": "05",
"year": "21"
},
"number": "5123456789012346"
}
},
"type": "CARD"
}
}
Issue #3: Authorization required
Fix: If using Postman, click on "Authorization", set "Type" it to Basic Auth, for "Username" set it to merchant.YOUR_MERCHANT_ID, for "Password" set it to YOUR_API_PASSWORD
Issue #4 (stuck here): Value '9999999999999999' is invalid. Card token must not be supplied
Method: PUT
URL: https://test-my.sample.gateway.mastercard.com/api/rest/version/46/merchant/MY_MERCHANT_ID/token/9999999999999999
Authorization: set correctly in Authorization tab
Body > raw:
{
"sourceOfFunds": {
"provided": {
"card": {
"expiry": {
"month": "05",
"year": "21"
},
"number": "5123456789012346"
}
},
"type": "CARD"
}
}
Response:
{
"error": {
"cause": "INVALID_REQUEST",
"explanation": "Value '9999999999999999' is invalid. Card token must not be supplied",
"field": "tokenid",
"validationType": "INVALID"
},
"result": "ERROR"
}
Q: Not sure what to do to tokenize the transaction..?! I'm stuck with issue #4.
Ok, finally figured it out. MPGS has 2 ways to create/update tokens:
Tokenization where YOU provide the token (notice: PUT method)
Tokenization where MPGS generate the token for you (notice: POST method)
They're very similar.
I got it working with the 2nd option.
Note: This is POST method !!
Method: POST
URL: https://SUBDOMAIN_YOU_SHOULD_BE_USING.mastercard.com/api/rest/version/50/merchant/YOUR_MERCHANT_ID/token
In postman, set Authorization (as described in the question, in issue #3).
Sample data to send (in postman, this should be in Body > raw):
{
"sourceOfFunds": {
"provided": {
"card": {
"expiry": {
"month": "05",
"year": "21"
},
"number": "5123456789012346"
}
},
"type": "CARD"
}
}
Sample response:
{
"repositoryId": "1000000000002",
"response": {
"gatewayCode": "BASIC_VERIFICATION_SUCCESSFUL"
},
"result": "SUCCESS",
"sourceOfFunds": {
"provided": {
"card": {
"brand": "MASTERCARD",
"expiry": "0521",
"fundingMethod": "CREDIT",
"issuer": "BANCO DEL PICHINCHA, C.A.",
"number": "512345xxxxxx2346",
"scheme": "MASTERCARD"
}
},
"type": "CARD"
},
"status": "VALID",
"token": "9717501974559694",
"usage": {
"lastUpdated": "2019-02-25T09:36:54.928Z",
"lastUpdatedBy": "1015",
"lastUsed": "2019-02-25T09:36:54.928Z"
},
"verificationStrategy": "BASIC"
}

Instagram Graph API - Get comments for media

I am trying to get comments for some business account by using business discovery node. I can load list of media with the request
GET
https://graph.facebook.com/v3.1/17841402914723639?fields=business_discovery.username(bluebottle){followers_count,media_count,media{media_type,comments_count}}
This returns
{
"business_discovery": {
"followers_count": 297515,
"media_count": 1317,
"media": {
"data": [
{
"media_type": "IMAGE",
"comments_count": 18,
"id": "17970528943031455"
},
{
"media_type": "IMAGE",
"comments_count": 17,
"id": "17938949563163035"
},
{
"media_type": "IMAGE",
"comments_count": 66,
"id": "17966264041064104"
},
I assume the id in the media entry is an id for that object. But when I am trying to access it like
GET https://graph.facebook.com/v3.1/17970528943031455
I got an error
{
"error": {
"message": "Unsupported get request. Object with ID '17970528943031455' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
"type": "GraphMethodException",
"code": 100,
"error_subcode": 33,
"fbtrace_id": "HbaasWNQ8ko"
}
}
Is it permission problem?
How can I get list of comments for a media?
According to the documentation: "An access token from a User who created the IG Media object, with the following permissions:" means that you need to have access permission granted by the owner of the post to have access to its comments.
The syntax of the query is :
business-account-id?fields=business_discovery.username(bluebottle){media{comments}}
But when I tried that I got this error :
{
"error": {
"message": "(#100) Please read documentation for supported fields.",
"type": "OAuthException",
"code": 100,
"fbtrace_id": "BFuJQt0/Kt3"
}
}
So I'm guessing they have removed the support for fetching the comments.
You can only get comments if you have a valid authentication token for the account you are querying. You would use the /media or <media_id>/comments endpoint to get comments, insights, etc:
Media endpoint
/MY_IG_BUSINESS_ACCOUNT_ID/media?fields=id,caption,comments_count,children{media_url},comments.limit(50){id,timestamp,username,text},insights.metric(impressions,reach,engagement,saved,video_views)&limit=30
Comments endpoint:
/<MEDIA_ID>/comments/?fields=created_time,from,message,like_count&limit=50

Messenger chatbot send file

I'd like to send a file to the user, to do so I tried the request below, but it fails.
The docs are not clear about wether is_reusable is compulsory, but the request fails with the same error, even if I include it.
The download url works fine in a browser.
I have https://asd.com/ whitelisted for sure.
Request:
{
"recipient": {
"id": "157..."
},
"message": {
"attachment": {
"type": "file",
"payload":
{
"url":
"https://asd.com/s3/..."
}
}
}
};
Response: HTTP 500
{
"error": {
"code": 1,
"message": "An unknown error occurred",
"error_subcode": 99
}
}
The issue is resolved now. I didn't touch the code, so probably it was an error on Facebook's side, as #Josh Cole and HTTP 500 suggested.
Recently they making quite a few breaking changes... Few days ago they broke all the web views, now the files, whats next?
I'm marking this question solved.