Comments (15)
It appears that null value should be used explicitly as the proper workaround (reason why I am not seeing any issue). If we update the code we need to use @wolzogen cleaner version, so the pull request should be resubmitted with the cleaner/shorter code.
from fb-messenger-php.
from fb-messenger-php.
Thanks Jason for replying even on Sunday.
Yes, I cloned the latest code with the folders Menu and Messages along with FbBotApp.php file and update the same in mine.
Was their any particular update sent for Structured message of generic message type ? If so, please it would be great if you can link me to the commit so that I can cross check.
from fb-messenger-php.
Just tried the following code too, this also fails to work.
case 'generic': $bot->send(new StructuredMessage($message['sender']['id'], StructuredMessage::TYPE_GENERIC, [ 'elements' => [ new MessageElement("First item", "Item description", "", [ new MessageButton(MessageButton::TYPE_POSTBACK, 'First button'), new MessageButton(MessageButton::TYPE_WEB, 'Web link', 'http://facebook.com') ]), new MessageElement("Second item", "Item description", "", [ new MessageButton(MessageButton::TYPE_POSTBACK, 'First button'), new MessageButton(MessageButton::TYPE_POSTBACK, 'Second button') ]), new MessageElement("Third item", "Item description", "", [ new MessageButton(MessageButton::TYPE_POSTBACK, 'First button'), new MessageButton(MessageButton::TYPE_POSTBACK, 'Second button') ]) ] ], [ new QuickReplyButton(QuickReplyButton::TYPE_TEXT, 'QR button','PAYLOAD') ] )); break;
P.S : Other functionality are working, hence I am figuring out some code issue with particular 'generic' message type.
Curl error and json_encode were the major update done recently I believe only the FbBotApp.php.
from fb-messenger-php.
from fb-messenger-php.
Yes, it was working well before and then it got stopped working all of a sudden.
Basically when the http_build_query issue arose 2 days ago, I tried debugging and fixed the same by using json_encode which then I realised the same has been fixed here, which made be update my pimax lib for any other open issues too.
Since then the Generic template has stopped working and I haven't been able to find any temporary fix too.
Meanwhile tried a core php generic template php code too, it also failed to work.
I am bit confused, how come only Generic template not working.
Sample core php code I tried :
case 'test': $answer = ["attachment"=>[ "type"=>"template", "payload"=>[ "template_type"=>"generic", "elements"=>[ [ "title"=>"Welcome to fb bot", "item_url"=>"https://www.basezap.com/guide-to-flush-redis-databases-and-keys/", "image_url"=>"https://www.basezap.com/wp-content/themes/basezap/images/logo.png", "subtitle"=>"We\'ve got the right hat for everyone.", "buttons"=>[ [ "type"=>"web_url", "url"=>"https://google.com", "title"=>"View Website" ], [ "type"=>"postback", "title"=>"Start Chatting", "payload"=>"DEVELOPER_DEFINED_PAYLOAD" ] ] ] ] ] ]]; $senderID = $message['sender']['id']; $response = [ 'recipient' => [ 'id' =>$senderID ], 'message' => $answer ]; $ch = curl_init('https://graph.facebook.com/v2.6/me/messages?access_token='.Yii::app()->params['token']); // You need to update your token variable here. curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($response)); curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']); if(!empty($input)){ $result = curl_exec($ch); } curl_close($ch); break;
Can you please try above code, if it works for you ?
from fb-messenger-php.
@pulkit8 what does the $result
variable contain?
PS: this piece of code works fine for me
from fb-messenger-php.
The above code works, I forgot to correct this
if(!empty($input)){ $result = curl_exec($ch); } to $result = curl_exec($ch);
So, now the issue is only with the the library structured message of type Generic and List
Here is the error
{"error":{"message":"(#100) The parameter name_placeholder[elements][0][default_action][type] is required","type":"OAuthException","code":100,"fbtrace_id":"CI6GGsRsdTy"}}
I have submitted pull request for the fix.
Basically the MessageElement needs a check for non empty default action parameter. From now, facebook doesn't allow the particular parameter to be blank for structured message of type list and generic.
Thank you everyone for the support.
from fb-messenger-php.
from fb-messenger-php.
The code needs a fix to support generic and list type of structured message. It fails in absence of call action.
from fb-messenger-php.
from fb-messenger-php.
from fb-messenger-php.
HI,
I have same error too
And
[error] => Array
(
[message] => (#100) The parameter name_placeholder[elements][0][default_action][type] is required
[type] => OAuthException
[code] => 100
[fbtrace_id] => CzjZId6Micu
)
)
from fb-messenger-php.
FInally, Ifound a way for this sequence:
$rsp = $bot->send(new StructuredMessage($senderid, StructuredMessage::TYPE_GENERIC, [
'elements' => [
new MessageElement($user->getFirstName().' '.$user->getLastName(), ' ', $user->getPicture())
]
],
[
new QuickReplyButton(QuickReplyButton::TYPE_TEXT, 'QR button','PAYLOAD')
]
));
Problem is here:
new MessageElement($user->getFirstName().' '.$user->getLastName(), ' ', $user->getPicture())
construct of it is:
__construct($title, $subtitle, $image_url = '', $buttons = [], $url = '', $default_action = [])
Seems that better is to init default for $default_action = null...
To work, just i add on call null parameter:
new MessageElement($user->getFirstName().' '.$user->getLastName(), ' ', $user->getPicture(), null, null, null)
from fb-messenger-php.
Yes definitely the cleaner code should be updated. Have created a new pull request with the same.
Applying the patch would surely solve the problem for people referring the example code for development.
from fb-messenger-php.
Related Issues (20)
- Can't send local file HOT 4
- Quick Replies for Phone and Email-- Need to Update Source Code HOT 7
- Hi, There I have Error: SSL certificate problem: unable to get local issuer certificate HOT 5
- Method call() not working with http_build_query($data) for CURLOPT_POSTFIELDS HOT 9
- Photo url seems not visible in MessageElement HOT 3
- Regarding persistent_menu, set/update or case for the older users HOT 5
- NON_PROMOTIONAL_SUBSCRIPTION is a tag not a type HOT 4
- last_ad_referral & is_payment_enabled HOT 1
- How to send pre-formatted json response HOT 2
- Send to all users using batch messages HOT 1
- version post 2.8 HOT 1
- Chatbot doesn't work at ALL HOT 4
- missed ; on FbBotApp.php HOT 2
- Add tests and coverage via travis-ci HOT 5
- error on line 71 FbBotApp.php
- VideoMessage HOT 13
- Update minimum PHP version HOT 8
- $bot -> send does not work HOT 1
- How can i send message to group chat rather than user id ?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fb-messenger-php.