Huawei push API throws error saying token count is wrong in postman - huawei-mobile-services

Using push API continuously returns token count should within 1 and 1,000. Please find the API error in the screenshot.

The possible causes of this problem is, you have placed the “token” attribute in wrong place.
Solution:
Please keep your “token” attribute within the “message” object,.
enter image description here
For details, check the following documents:
https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/android-server-dev-0000001050040110

Your token is outside the message body, "token", "android" should be within the message body.
Please check the sample code here
Also, if you want to use more tokens (>1000), the best method is to invoke the API using App server and send messages in batches.

Related

Facebook Ads API: How can I create ads preview without create campaign first?

I check a lot of documents, and flow like that:
Submit data to create Campaign, target, and AdCreative
Use ID of AdCreative to generate preview code
Display preview code to my site (to show to my user)
But I don't want to create Campaign, Targeting, and AdCreative before preview, just submit raw data of AdCreative to get preview code.
I found that doc https://developers.facebook.com/docs/graph-api/reference/generatepreviews/, and look like they can solve my problem... But it didn't work.
My test data is: https://graph.facebook.com/v2.6/generatepreviews?ad_format=RIGHT_COLUMN_STANDARD&creative={"object_story_spec":{"link_data":{"message":"msg","link":"http://kimkha.com?1","caption":"ccccc"}},"name":"NAME 1","body":"dddddd","title":"titititit","call_to_action_type":"OPEN_LINK","object_url":"http://kimkha.com"}&access_token=<token>
And the error:
{
"error": {
"message": "(#275) Cannot determine the target object for this request. Currently supported objects include ad account, business account and associated objects.",
"type": "OAuthException",
"code": 275,
"fbtrace_id": "GeckbxpU9gr"
}
}
I ran into the same problem and got past it, despite not being able to get a fully-functioning dynamic preview working. Here are some more pointers to help save others the pain.
The url needs to include an "ad account, business account or associated objects" like the error message states. For my case I used my ad account id (https://www.facebook.com/business/help/1492627900875762). The url changed to be the following base format: https://graph.facebook.com/v2.10/act_<your-app-id>/generatepreviews
When you get the response, you need to decode the body and you can use the url directly to test. I replaced \/ with /, & with & and removed the trailing slash. After this you get a url that should give you more specific error messages
I had to also specify a "page_id" parameter that the ad will be associated with. This is a sibling of "link_data" in the sample JSON listed above.
You may get error messages telling you to change the format of certain fields.
Eventually I got the error "Preview Not Available: Unable to display a preview of this ad. (fbtrace_id: Dsfql/z/qVI)" and finally lost the will to continue. The documentation is far from easy to follow and does not have clear examples.
I'm sorry I can't give a working solution, but for my case I was evaluating this API for a non-critical piece of work and timeboxing prevented me from proceeding. Hopefully I help save some time for someone else.
I ran into this problem. The solution for me was to use my app token instead of the Graph API Explorer's token. Hope this helps!
My two cents after struggling on this issue. My request had to be formatted as follows (this is using video data, but should extend to link data):
act_{ACT_ID}/generatepreviews
?ad_format=DESKTOP_FEED_STANDARD
&creative={object_story_spec:{
page_id:<PAGE_ID>,
video_data: {
image_url: <IMAGE_URL>,
call_to_action:{
type:"SHOP_NOW",
value:{
link: <URL>
}
}
}
}}
In this case, the call_to_action has to be placed inside the video_data (or link_data) parameter and has to be formatted as an object. I did also have to change & with &, as Matt mentions.

Credits: Error occurs *sometimes*

I created a Facebook app and integrated Credits. However, about every second time I call the credits API, I get the following error:
There Was a Problem Processing Your Payment / Sorry, but we're having trouble processing your payment. You have not been charged for this transaction. Please try again later.
Everything on my end looks good. On success, the callback is called 3 times:
payments_get_items
payments_status_update, status "placed"
payments_status_update, status "settled"
When it fails and the above error dialog is shown, I can see that only the first call is performed (payments_get_items).
I can see that the response back to Facebook is the same in both cases:
{ "content":[ { "item_id":"1", "title":"[title]", "description":"[description]", "image_url":"[url]", "product_url":"[url]", "price":30 } ], "method":"payments_get_items" }
Has anyone experienced this or can imagine what the reason for the behaviour is?
Thank you!
Bw
I just had similar issue.
Error message is generic and it doesn't give you exact cause of the problem.
In my case the problem was that my image url was misspelled so check your payments_get_items response very carefully.
Beside checking image url validity also check that length of your title and description is ok.
check "Developers response" section on this url for info on boundaries :
https://developers.facebook.com/docs/payments/callback/#payments_get_items
BTW, I think they mistakenly marked product url as required, however you can put same value as for image url just to be sure.

Getting REQUEST_DENIED when calling Google's Autocomplete from a Browser

I have signed up for Google Places Autocomplete API and created a new key by going to following url.
http://code.google.com/apis/console/
I am using the generated key to do some testing on my browser. I am entering following url to search for City names starting with "San".
https://maps.googleapis.com/maps/api/place/autocomplete/json?input=San&types=cities&sensor=false&key=
I keep getting "REQUEST_DENIED" error message. Is there anything I am missing? I can see my usage counter going up every time I try to test this using a browser, but I keep getting REQUEST_DENIED message back. As per the google documentation it says this message is related to "Sensor" parameter. I tried setting this parameter to True/False but get the same results. Please help!
Thanks,

Real-time updates Facebook app subscription issue

I have been trying to subscribe to real-time updates for the past week and I have been unsuccessful.
When I do the HTTP post (using rest-client) to URL:
https://graph.facebook.com/<app-id>/subscriptions
...I get this error message as response:
{"error":{"message":"(#100) The parameter object is required","type":"OAuthException"}}
My header parameters were as follows:
access_token=***,
object=user,
fields=friends,
callback_url=https://aaa.appspot.com,
verify_token=(app secret key)
I'm not able to find where I'm going wrong.
Somebody please kindly guide/help me figure my mistake.
The below link was used as a reference.
http://www.fb-developers.info/tech/fb_dev/tutorial/bytopic/realtime_upd_02.php
Thanks you for your time in advance.
You need to send your request to https://graph.facebook.com/appid/subscriptions and not https://graph.facebook.com/subscriptions - although that might be an error in your question and not your code!
EDIT: I just checked the markup for your question and you do have appid in the URL, it just wasn't displaying properly
How are you getting the access token? You must use an application access token and not a user access token, i.e. retrieve the access token from https://graph.facebook.com/oauth/access_token?client_id=<APP_ID>&client_secret=<APP_SECRET>&grant_type=client_credentials
https://developers.facebook.com/docs/reference/api/realtime/ is the official documentation, that might be more up to date than the link you've been using.

How to obtain new facebook access token

I looked all over facebook api docs for FLEX and i couldn't find a way to obtain a new access token, can anyone please guide me how to that?
By the way , the only time I get error "access token" is when I try to get information from the api and using the parameter "since".
when I use this call, im getting a token error message
FacebookDesktop.api("me/likes?since=1319917311",handleFeed);
and when im using it without since
FacebookDesktop.api("me/likes",handleFeed);
I get no error message
anyway the main issue is how to obtain a new access token
10x!
You should use third argument of FacebookDesktop.api method to pass additional parameters:
FacebookDesktop.api("me/likes",handleFeed, {
since:1319917311
});