pimax/fb-messenger-php

How can I make generic structured message with many elements?

Closed this issue · 3 comments

Hi, really stuck on this one,.. I do a normal curl, but fb shows recipient required even though I've done all correctly. so I have to use your libs.

but the problem is how can I populate elements, it's impossible for me to create MessegeElement everytime inside the loop. thanks

hi bil, you can create function getMessageButtonObject and getMessageElementObject which returns
their respective objects(pass appropriate args) . You can store these objects in array and later pass that array to structuredMessage. I hope this helps.

Hi bol,
Fb response suggests it didn't received recipient ID. Make sure to include
that in your request. Also Is this problem occurring only with generic
message or with any message type. Are you able to send simple Imagemessage.
Also it would be helpful if can upload you json response.
Kapil
On 15-Aug-2016 9:20 am, "Bilal Luqman Bayasut" notifications@github.com
wrote:

thanks kapilk, But I've tried replicated their respective returned object
but still it can't work.
In fact, I've constructed my own json Obj and send it to fb via cURL, but
fb returned recipient required.
any idea?

` // $ch = curl_init($app->fb_api_url.'me/messages?access_token='.$
app->token);
// //Tell cURL that we want to send a POST request.
// curl_setopt($ch, CURLOPT_POST, 1);
// //Attach our encoded JSON string to the POST fields.
// curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($another_result));
// //Set the content type to application/json
// curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept' =>
'application/json'));

                //  $result = curl_exec($ch);
                //  curl_close($ch);
                // print_r(json_decode($result,true));

`

there is my code


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#28 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AHwULkuDenlam1UbO59NzKKEaUKTbBphks5qf-IUgaJpZM4Jj80g
.

solved?