Method call() not working with http_build_query($data) for CURLOPT_POSTFIELDS
Closed this issue · 9 comments
o2-web commented
FbBotApp.php in method call() in this part of the code, I had to change http_build_query
to json_encode
, because if you use http_build_query
then when sending a message Facebook returns an error:
Array
(
[error] => Array
(
[message] => An active access token must be used to query information about the current user.
[type] => OAuthException
[code] => 2500
[fbtrace_id] => D5nVvpItwir
)
)
but working good if:
if ($type == self::TYPE_POST || $type == self::TYPE_DELETE) {
curl_setopt($process, CURLOPT_POST, 1);
// curl_setopt($process, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($process, CURLOPT_POSTFIELDS, json_encode($data));
}
is that just me?
jason-engage commented
What's in your $data variable? Httpbuildquery has always worked fine for
me, but perhaps you have some special data or you should serialize you data
before sending it.
--
* Jason Shaw <jason@engageify.com>*, Developer
Tel. 647 783 7463 | Skype: jason.engage
en.gg | <http://en.gg/>Follow me on Facebook
<http://www.facebook.com/engagetheweb>
o2-web commented
[2018-06-22 23:27:53] local.INFO: $data = Array
(
[recipient] => Array
(
[id] => 1614553048605991
)
[message] => Array
(
[text] => test111
)
[tag] =>
[notification_type] => REGULAR
[messaging_type] => RESPONSE
[access_token] => EAAb8AuRIi2wBAJnjfIXUPEGixBmZBIkjLXFiICUXG5EkJK4XcF7ZAjqhiCTnsPZAXIrgmBzhgL05OdXlfD0nseZAssZBQRIpI3SB01oG8dv6WALDwAkZCHXqss7ilBmIQIjfQVk0ZCEA36PJHasZBpWxmZBRXNV6U8ZB1V3DF0HkxrnyqcK6xnrQdn
)
jason-engage commented
Doesn't look special.
--
* Jason Shaw <jason@engageify.com>*, Developer
Tel. 647 783 7463 | Skype: jason.engage
en.gg | <http://en.gg/>Follow me on Facebook
<http://www.facebook.com/engagetheweb>
o2-web commented
@jason-engage does it work fine for you with http_build_query
now?
a couple of days ago I was working fine with http_build_query
, but today I had to change to json_encode
jason-engage commented
Did your problem just start today?
I have a bot running all the time but it stopped working 12 hours ago. I'm
not sure if this is related, but I have to look into it asap, and I'll get
back to you.
o2-web commented
@jason-engage this problem I noticed yesterday, but only today found a way to get rid of it
jason-engage commented
Ah perhaps you're right then I'll test your fix and if working I'll push it
jason-engage commented
Yes, you're right, the json_encode is necessary
o2-web commented
I think the issue can be closed. Saw the last commit. Thank you!