softon / sms

Simple SMS Gateway Package for sending short text messages from your Application. Facade for Laravel 5(Updated to work with Laravel 5.5).Currently supported Gateways Clickatell, MVaayoo, Gupshup, SmsAchariya, SmsCountry, SmsLane, Nexmo, Mocker / Any HTTP/s based Gateways are supported by Custom Gateway. Log gateway can be used for testing.
http://softon.github.io/sms/
MIT License
45 stars 27 forks source link

Multiple messages send to same user #6

Closed tiipiik closed 7 years ago

tiipiik commented 7 years ago

Hi,

I'm using your plugin to send messages to users about meetings. Actually all messages are send to the first number. If I use the Log gateway it records every message send to the good user (different from what it really appends), so I think it's probably a mistake in my code but I can't find where. Any help would be greatly appreciated.

use Softon\Sms\Facades\Sms;

public function sendingSms()
{
    $day = Carbon::now();

    $fake_meetings = collect([]);

    $first = new stdClass();
    $first->phone = '0600000000';
    $first->date = $day->copy()->setDate(2017, 2, 21)->setTime(9, 0, 0);
    $fake_meetings->push($first);

    $second = new stdClass();
    $second->phone = '0600000001';
    $second->date = $day->copy()->setDate(2017, 2, 21)->setTime(9, 20, 0);
    $fake_meetings->push($second);

    $fake_meetings->each(function ($meeting) {
        $date = $meeting->date;
        $date = utf8_encode($date->formatLocalized('%A %d %B %Y %H:%M'));

        $message_datas = [
            'begins_at' => $date,
        ];

        self::getSmsRecall($meeting->phone, $message_datas);
    });
}

And the method that use your plugin to send messages

private static function getSmsRecall($phone, $message_datas)
{
    $r = Sms::send($phone, 'sms.recall', [
        'begins_at' => $message_datas['begins_at'],
    ]);
}
tiipiik commented 7 years ago

I finally find the origin of the problem : in your ClickatellGateway.php you did not define the $this->request variable in the getUrl() method, so $this->request will concatenate all the requests passed.

Add

$this->request = '';

on line 25 fixed the problem.

softon commented 7 years ago

Its there in line 13. also the function composeBulkMobile() handles the concatenating of the numbers.

tiipiik commented 7 years ago

Oh yeah your totally right, but for me it didn't seems to work and I have had to add this line to get things done properly. Maybe it's only for me and the issue is not due to your code directly.