I'm trying to implement the buy button in my messenger bot, but getting these 2 errors:
{"error":{"message":"(#-1) Send API unexpected internal error","type":"OAuthException","code":-1,"error_subcode":2018012,"fbtrace_id":"BN47MpNqWNN"}}
{"error":{"message":"(#100) Invalid button type","type":"OAuthException","code":100,"error_subcode":2018037,"fbtrace_id":"Agfk\/h+cEta"}}
Any ideas what the issue could be? Where can I look up these error codes?
This is the message I'm sending to Facebook's messenger API:
{'message': {'attachment': {'type': 'template', 'payload': {'text': 'Please checkout.', 'template_type': 'button', 'buttons': [{'payment_summary': {'merchant_name': "Peter's Apparel", 'currency': 'USD', 'payment_type': 'FIXED_AMOUNT', 'price_list': [{'amount': '29.99', 'label': 'Subtotal'}, {'amount': '2.47', 'label': 'Taxes'}], 'requested_user_info': ['contact_name'], 'is_test_payment': True}, 'type': 'payment', 'payload': 'DEVELOPER_DEFINED_PAYLOAD', 'title': 'buy'}, {'type': 'postback', 'payload': '{"title": "Confirm Order", "event_value": "", "event_name": "confirm_order"}', 'title': 'Confirm Order'}, {'type': 'postback', 'payload': '{"title": "Add Coupon Code", "event_value": "", "event_name": "add_coupon"}', 'title': 'Add Coupon Code'}]}}}, 'recipient': {'id': '1232211580183568'}}
"The Buy Button only works with the Generic Template and List Template and it must be the first button."
Your template type is 'button'. Try to change your template_type to generic or list. Also, make sure you have access to beta program for payments.
Reference: https://developers.facebook.com/docs/messenger-platform/send-api-reference/buy-button
Related
I can't send PATCH request to my REST API to send node with translations.
The error is 422 Unprocessable Entity: validation failed. title: Title: this field cannot hold more than 1 values.
I was trying JSON:API and REST, but the only way I found is to manually create translations, and after that update each translation separately.
The data I'm trying to PATCH to REST is
const data = {
'type': 'charset',
'title': [
{ 'value': sName1, 'lang': 'en' },
{ 'value': sName2, 'lang': 'ru' },
],
'field_unicode_range': [{ 'from': iFrom, 'to': iTo }],
};
The JSON:API does not seem to currently support translations (Nov 2021).
"does support PATCH requests on translations: updating translations is possible" source.
There does seem to be some work going on around this is this issue
I am working with paypal subscription api v1. When an user subscribe to one of my plans on my website, the subscription_id is sent to my server. There I check the status and next billing date using the subscription details api to give the user some value. But when the user subscribes and my server checks for the status, the response it is getting is confusing. The response json is given below:
{'status': 'ACTIVE',
'status_update_time': '2019-11-13T09:36:35Z',
'id': '***',
'plan_id': '***',
'start_time': '2019-11-12T16:00:00Z',
'quantity': '1',
'shipping_amount': {'currency_code': 'USD', 'value': '0.0'},
'subscriber': {'name': **, 'email_address': '***', 'shipping_address': **},
'billing_info': {
'outstanding_balance': {'currency_code': 'USD', 'value': '0.0'},
'cycle_executions': [{
'tenure_type': 'REGULAR',
'sequence': 1,
'cycles_completed': 0,
'cycles_remaining': 0,
'current_pricing_scheme_version': 1,
'total_cycles': 0
}],
'next_billing_time': '2019-11-13T09:36:33Z',
'failed_payments_count': 0
},
'create_time': '2019-11-13T09:35:46Z',
'update_time': '2019-11-13T09:36:35Z',
Here you can see that the status is active but the next_billing_time is less than the status_update_time. And also no payment cycle is completed. Why paypal is behaving like this? I think the status should not be "ACTIVE" if the cycle is not complete. So why is it giving active status?
I'm trying to post with POSTMAN to the new IBM Watson work services but only get one error after the other.
This documentation does not clearly explain the body scheme for messages (or does it?):
https://workspace.ibm.com/developer/docs#genericannotation
So I'm guessing around:
POST to
https://api.watsonwork.ibm.com/v1/spaces/{spaceId}/messages
With headers:
Content-Type:application/json
Authorization:Basic 123456789
spaceId: MySpaceID
body:{"input": {"text": "Hello"}}
What's the right scheme for the body to post that message with success?
I always get the following error:
{
"timestamp": "2016-10-27T12:53:07.134+0000",
"status": 403,
"error": "Forbidden",
"message": "No message available",
"path": "/teams/{spaceId}/messages"
}
I create a Script on GitHub, you can have more details on file PostMessageOnWatsonWorkspace.py
I put part of the code below
appname = 'PostMessageOnWatsonWorkspace'
text = """
Visit [IBM site](http://www.ibm.com), and leave a *message*.
Have _fun_!!!
Code Line:
`code`
Code Block:
```
code block
```
Bye
"""
Currently to format has only Bold, Italic, Code and links.
And this is an example of Post data.
data = {
'type': 'appMessage',
'version': 1.0,
'annotations': [{
'type': 'generic',
'version': 1.0,
'color': '#4FC3F7',
'title': appname + ' --> sendRichMessage at ' + str(datetime.datetime.now()),
'text': text,
'actor': {
'name': 'Enio Basso',
'avatar': '',
'url': 'https://ebasso.net'
}
}]
}
Other details you can find on documentation.
I'm using XFBML embedded in a HTML5 document. I've set up client-side validation following the instructions provided in the "Registration Advanced Uses" doc on Facebook's site, but it only shows errors on blur, and doesn't validate when I click the "Register" button (so if I fill out a field wrong and click outside on another element, it displays the error, but then I can click on the Register button and it registers me anyway).
I've traced it in the JS debugger, and by adding alert/log statements, and my validate_registration function only gets called onblur, and never when I click the Register button.
Anyone seen this behavior and know what I'm missing here? The live example Facebook has on the "Registration Advanced Uses" works perfectly, so I know I've got a mistake somewhere.
My XFBML tag is this:
<div class="fb-registration"
onvalidate="validate_registration"
fields="[
{'name': 'name'},
{'name': 'first_name'},
{'name': 'gender'},
{'name': 'email'},
{'name': 'user_type', 'description': 'Are you a?', 'type': 'select',
'options': {
'parent': 'Parent/Guardian looking for childcare',
'sitter': 'Babysitter/Nanny looking for sitting jobs'
}
},
{'name': 'zip_code', 'description': 'Zip code', 'type': 'text'},
{'name': 'over_eighteen', 'description': 'I am at least 18 years old', 'type': 'checkbox' }
]"
fb_only="true"
redirect-uri="<%= parse_fb_connect_signed_request_users_url %>"
width="530">
</div>
and my validation function is this:
function validate_registration (custom_fields) {
var errors = {},
regexZipCode = /^\d\d\d\d\d$/;
console.log("in validate_registration");
if (custom_fields.user_type !== 'parent' && custom_fields.user_type !== 'sitter') {
errors.user_type = "Select either Parent or Sitter";
}
if ( ! regexZipCode.test(custom_fields.zip_code) ) {
errors.zip_code = 'Enter your 5-digit U.S. zip code';
}
if ( ! custom_fields.over_eighteen ) {
errors.over_eighteen = 'You must be at least 18 years old to use this site!';
}
return errors;
}
So, never mind this.
I was getting the message "You've just registered for X using your Facebook account.
If you didn't mean to do this, you can undo this below." and thought that it meant I had registered. But if I click "Continue" at that point, it shows me all the validation errors, so it does work correctly - it just doesn't validate until after the final step.
I am trying to make a Facebook dialogue appear when the user completes an event and so I built this function.
function post_to_wall_popup(){
FB.init({ apiKey: 'Super Secret API Key' });
var publish = {
method: 'stream.publish',
attachment: {
name: 'XYZ',
caption: 'caption here',
description: ('description'),
href: 'url',
media: [{
type: 'image',
href: 'url',
src: 'xyz.gif'
}]
},
action_links: [{ text: 'XYZ', href: 'url' }]
};
FB.ui(publish,null);
}
I have tried a few different examples that are supposed to have similar results but on each one all I get is the dialog box with "Loading.." for a split second, then it disappears.
Has anyone else ever come across a similar problem?
Make sure that fb-root is defined & visible.