Skip to content

Bug: defined property: stdClass::$id #101

@sts-ryan-holton

Description

@sts-ryan-holton

👋 Hi,

Just reaching out as I've identified a problem with the getReceiver function, firstly, not quite sure why I'm getting the error in the first place, I'm using v8.0.0 of the package, getting the error:

ErrorException: Undefined property: stdClass::$id in /var/www/domain-monitor-api/vendor/laravel-notification-channels/twitter/src/TwitterDirectMessage.php:45

Presumably the error handling of the $user->id here needs to be more robust?

/**
 * Get Twitter direct message receiver.
 *
 * @return string|mixed
 *
 * @throws CouldNotSendNotification
 */
public function getReceiver(TwitterOAuth $twitter): mixed
{
    if (is_int($this->to)) {
        return $this->to;
    }

    $user = $twitter->get('users/show', [
        'screen_name' => $this->to,
        'include_user_entities' => false,
        'skip_status' => true,
    ]);

    if ($twitter->getLastHttpCode() === 404) {
        throw CouldNotSendNotification::userWasNotFound($twitter->getLastBody());
    }

    return $user->id;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions