Code Monkey home page Code Monkey logo

messenger's People

Contributors

atgg avatar bfoucher avatar dbknet avatar gregweston avatar htaoufikallah avatar ker0x avatar khodl avatar mferrara avatar misantron avatar nferbei avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

messenger's Issues

3.4.1 release?

Can see from: cf773c1 Guzzle has been bumped to v7. Packagist defaults to 3.4 release which only has Guzzle 6.2 and causes compatibility issues. Are we able to get an updated release with these library bumps, please?

app_id in echo message

Notice: Undefined index: app_id /vendor/kerox/messenger/src/Model/Callback/MessageEcho.php on line 86

It happen when the app subscribed to echo messages, and the user click on "Send Message" on a page's post. Facebook then sends the post as a message, and that's probably why the app_id doesn't exist.

Here is an example of data:

{"object":"page","entry":[{"id":"123456789","time":987654321,"messaging":[{"sender":{"id":"123456789987654321"},"recipient":{"id":"987654321123456789"},"timestamp":1503948277841,"message":{"is_echo":true,"mid":"mid.$XXXXXXXXX","seq":100000,"attachments":[{"title":"Here is an example","url":null,"type":"template","payload":null}]}}]}]}

Remove Guzzle in flavor of PSR-18

As soon as the PSR-18 will be accepted, we need to:

  • remove guzzlehttp/guzzle from required package
  • add psr/http-client instead
  • rework API classes to take into account ClientInterface

Messaging type should be MESSAGE_TAG for tagged messages.

Tried to send message with tag
$messenger->send()->message('', '', Send::NOTIFICATION_TYPE_REGULAR, Send::TAG_ISSUE_RESOLUTION);

I got error
Fatal error: Uncaught GuzzleHttp\Exception\ClientException: Client error: POST https://graph.facebook.com/v2.11/me/messages?access_token= resulted in a 400 Bad Request response:
{"error":{"message":"(#100) Messaging type should be MESSAGE_TAG for tagged messages.","type":"OAuthException","code":10 (truncated...)
in /vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113

I don't know whether i made mistake in my code. but it looks like messaging_type is not set correctly so i reported it.

Datatype of timezone is float

In UserResponse class the datatype of timezone is int. But I get my timezone as 5.5 (+5:30). So the datatype of timezone may be float. I got error as

PHP Fatal error: Uncaught TypeError: Return value of Kerox\Messenger\Response\UserResponse::getTimezone() must be of the type integer or null, float returned in /vendor/kerox/messenger/src/Response/UserResponse.php:105

Allow sending messages with `user_ref` recipient

Description
I am trying to send a message with a user_ref string (received from Messenger Checkbox), this is not possible though, because the constructed message has pretty much hardcoded recipient with id key.

Example

It could be perhaps done just by removing type string for $recipient from message on Send and ?string type in the constructor of SendRequest.

Then the following should work:

$messenger->send()->message(['user_ref' => $recipient], $message);

And the constructed message would comply with the format specified here.

{
  "recipient": {
    "user_ref":"<UNIQUE_REF_PARAM>"
  }, 
  "message": {
    "text":"hello, world!"
  }

0 is an empty text

Sometimes a user may want to send the text "0", which is detected as empty in this line: https://github.com/ker0x/messenger/blob/master/src/Model/Callback/Message.php#L85

I'm not sure it's the expected behaviour (even if it's PHP's empty normal behaviour) in a chat situation.

Probably if it's a Message event, it means that there is at least at text and we shouldn't even test hasText. Is it sure enough to trust that? Or is it possible that there are only attachments without text?

Version number not in url

It seems that paths like /me/messages are transformed to https://graph.facebook.com/me/messages instead of https://graph.facebook.com/v2.6/me/messages. It caused me a problem that was solved that way, by hardcoding version number

As far as I know, it's GuzzleHttp that make this uri conversion.

The simple version would be to set base_uri to self::API_URL.self::API_VERSION.'/' and change routes to me/messages (relative path) instead of /me/messages (from domain root)

Is there a cleaner way to do it?

Error with 'seq' parameter

Hello,

I am currently working on a project using your bundle
We have a problem with quick replies that no longer call their callback function since the beginning of this month of August.
While looking in our logs, we could see the following error:

[2019-08-19 15:29:11] request.CRITICAL: Uncaught PHP Exception Symfony\Component\Debug\Exception\FatalThrowableError: “Type error: Argument 2 passed to Kerox\Messenger\Model\Callback\Message::__construct() must be of the type integer, null given, called in /var/www/v2/releases/448/vendor/kerox/messenger/src/Model/Callback/Message.php on line 157” at /var/www/v2/releases/448/vendor/kerox/messenger/src/Model/Callback/Message.php line 49 {“exception”:“[object] (Symfony\Component\Debug\Exception\FatalThrowableError(code: 0): Type error: Argument 2 passed to Kerox\Messenger\Model\Callback\Message::__construct() must be of the type integer, null given, called in /var/www/v2/releases/448/vendor/kerox/messenger/src/Model/Callback/Message.php on line 157 at /var/www/v2/releases/448/vendor/kerox/messenger/src/Model/Callback/Message.php:49)“} []

At the root of the problem would be an update of Messenger that would no longer use the ‘seq’ parameter:
« Effective as of today, the parameter seq will always be 0 for all Messenger webhook events. This deprecation was announced on November 8, 2016. After Jul 31, 2019 the seq parameter will no longer be included in webhook events. To de-duplicate messages use the mid parameter. »
--> https://developers.facebook.com/docs/messenger-platform/changelog

This is the reason why the bundle should be updated so that this parameter will no longer be present or will be modified and that the quick replies return to normal operation.

Problem in object instantiation

Hi Mr Ker0x i hope you doing well,
Sir we are using ker0x messenger sdk and our team having object instantiate problem. Let me explain

In figure 1.1
you can see that we are ceating 2 objects
$messenger1 (on line 33)
$messenger2 (on line 34)

with pageToken
abc (on line 33)
xyz (on line 34)

respectively.

Then we simple var_dump the objects on line number 40 and 49 respectively.

In figure 1.2
you can see the results that we are having same pageToken for both objects i.e. pageToken is abc for $messenger1 and $messenger2, for $messenger2 it should be xyz

So we debug the problem and found some piece of code that may be creating the problem i.e. in figure 1.3 you can see code snippet
In this code you are saving instance in static variable $_instance which doesn't get reinitialize while creating new object.

so i hope you can understand the problem and will be fixing it soon.

PS: problem persists in both versions i.e. 1.x and 2.x and we are using version 1.4

best Regards

figure 1 1
figure 1 2
figure 1 3

On "standby" event, Postback doesn't contain payload

FYI, it's possible that a Postback event doesn't contain payload. For instance when standbywebhook is set, we may also receive this event:

{
    "object": "page",
    "entry": [
        {
            "id": "270383946729865",
            "time": 1504876176615,
            "standby": [
                {
                    "recipient": {
                        "id": "270383946729865"
                    },
                    "timestamp": 1504876176615,
                    "sender": {
                        "id": "1260743020679416"
                    },
                    "postback": {
                        "title": "Details"
                    }
                }
            ]
        }
    ]
}

When someone click on a list's button, it will send the normal event (with payload), and also the standby one.

It may cause a problem there: src/Model/Callback/Postback.php on line 62

It's not important in my case, I simply deactivated the standby webhook. Just wanted to let you know about it.

Parse error: syntax error, unexpected 'const'

[2018-01-16 12:56:39] lumen.ERROR: Symfony\Component\Debug\Exception\FatalThrowableError: 
Parse error: syntax error, unexpected 'const' (T_CONST), expecting variable (T_VARIABLE) in
C:\xampp2\htdocs\faceman\vendor\kerox\messenger\src\Messenger.php:23

Code Line:

class Messenger
{
    public const API_URL = 'https://graph.facebook.com/';
    public const API_VERSION = 'v2.11';

    /**
     * @var string
     */

Subdomains considered invalid URLs

I'd fix this myself and submit a pull request but I'm not very handy with regex and wouldn't want to muck things up...

I'm running into situations where urls with subdomains are coming back as invalid URLs from the isValidUrl method linked below - is this intended?

'/^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&\/=]*)$/',

Improve all callback class

  • Add a method to check if Postback has a referral
  • Add a method to check if AccountLinking as an authorization code

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.