Mwangangi / ci-africastalking

Africa's Talking PHP Library modified for Codeigniter.
2 stars 5 forks source link

returning error response #3

Open copenju opened 3 years ago

copenju commented 3 years ago

Hi a good tool just wanted to inquire how to return responses in case the SMS was not send based on your tool am not good in PHP //Using the default sender ID

$this->africastalking->sendMessage($recipients, $message);

///??response stutus/////

Mwangangi commented 3 years ago

@SamuelMwangiW kindly assist

SamuelMwangiW commented 3 years ago

@copenju Kindly confirm if you are using Codeigniter or any framework at all.

SamuelMwangiW commented 3 years ago

This package was written a while back for Codeigniter 3. If the config's properly configured with AT Username and API, calling $this->africastalking->sendMessage($recipients, $message); with an array of recipients and the string message, the method returns the Africastalking response object. https://github.com/Mwangangi/ci-africastalking/blob/bb2601bcb3e8e5d7e9cc25ae2c4dc23db117e995/application/libraries/Africastalking.php#L19-L52 @Mwangangi in your opinion, should we upgrade the package to CI4?

Mwangangi commented 3 years ago

Yes, the project needs an upgrade to CI4. However, I am not able to handle that at the moment. I'm too held up to make such a commitment. @SamuelMwangiW if you're able to, kindly do.

copenju commented 3 years ago

Yes please kindly if you the capacity to upgrade it will be okay I support this

On Wed, 24 Feb 2021, 20:46 Mwangangi, notifications@github.com wrote:

Yes, the project needs an upgrade to CI4. However, I am not able to handle that at the moment. I'm too held up to make such a commitment. @SamuelMwangiW https://github.com/SamuelMwangiW if you're able to, kindly do.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Mwangangi/ci-africastalking/issues/3#issuecomment-785254976, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMGI7MUDLIMQ5GC35LUD6E3TAU3PTANCNFSM4YCO6CSA .

copenju commented 3 years ago

ok hi mwangi this all we to do in the controller, just call this sendMessage() and assign it a variable //.............. $result_array=$this->africastalking->sendMessage($recipient["contact"], $message); //logic here ...

SamuelMwangiW commented 3 years ago

@copenju kindly paste here the error you are getting

copenju commented 3 years ago

@copenju kindly paste here the error you are getting

ok I had a problem with getting the response but I have sorted it out as you explained earlier , it's now ok I was tagging @Mwangangi, the names look the same

SamuelMwangiW commented 3 years ago

@Mwangangi Its been years now since I was using CodeIgniter. I now see that CI4 supports composer natively out of the box. I will spare some time over a week and create a simple CI library based on composer

copenju commented 3 years ago

@Mwangangi Its been years now since I was using CodeIgniter. I now see that CI4 supports composer natively out of the box. I will spare some time over a week and create a simple CI library based on composer

ok that will be great its also as if Africas talking are no longer advocating PHP library

SamuelMwangiW commented 3 years ago

@copenju That's actually not the case, the offcial SDK is actively developed repo and you can find it here https://github.com/AfricasTalkingLtd/africastalking-php and their docs also prominently include PHP code samples (https://developers.africastalking.com/docs/sms/sending/bulk). This was a wrapper around the official SDK

copenju commented 3 years ago

Thanks, I'll check them out.

On Fri, Feb 26, 2021 at 11:36 AM Samuel Mwangi notifications@github.com wrote:

@copenju https://github.com/copenju That's actually not the case, the offcial SDK is actively developed repo and you can find it here https://github.com/AfricasTalkingLtd/africastalking-php and their docs also prominently include PHP code samples ( https://developers.africastalking.com/docs/sms/sending/bulk). This was a wrapper around the official SDK

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Mwangangi/ci-africastalking/issues/3#issuecomment-786496057, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMGI7MRCYAGJLBXDMWYEA3LTA5MPVANCNFSM4YCO6CSA .

GurupriyaWebvillee commented 3 years ago

Hello, i am getting this error

An uncaught Exception was encountered Type: AfricasTalkingGatewayException

Message: The supplied authentication is invalid

Filename: /var/www/html/sery_new/application/third_party/AfricasTalkingGateway.php

Line Number: 103

Backtrace:

File: /var/www/html/sery_new/application/controllers/Admin.php Line: 3258 Function: sendMessage

File: /var/www/html/sery_new/index.php Line: 315 Function: require_once

GurupriyaWebvillee commented 3 years ago

i am using like this

public function sms(){ $this->load->library('africastalking');

    $recipients = "89685748574";
    $message = "fghh";
    $this->africastalking->sendMessage($recipients, $message); 

}
copenju commented 3 years ago

is that phone number correct

SamuelMwangiW commented 3 years ago

@GurupriyaWebvillee I also suspect the username and api key supplied in the config might also be a problem given the error:

Message: The supplied authentication is invalid
GurupriyaWebvillee commented 3 years ago

I am giving username - sandbox, and key - sandbox key. and also i am giving now my correct phone number.

Controller - public function sms(){ $this->load->library('africastalking');

    $recipient["contact"] = "8770186120";
    $message = "Test message";
    $sender_id = 'TestSender';
    $result_array = $this->africastalking->sendMessage($recipients, $message,$sender_id);

}

Config- $config = array( 'username' => 'sandbox', 'apiKey' => '1bdff728b5ddc1e9638d8a98c07c0be699e431f8c8538a91341e19b3d734114c', 'default_country_code' => '+91',//254 'sms_sender' => 'AFRICASTKNG' //Leave as NULL to send using the default senderId 'AFRICASTKNG' );

Error An uncaught Exception was encountered Type: AfricasTalkingGatewayException

Message: Please supply both to and message parameters

Filename: /var/www/html/sery_new/application/third_party/AfricasTalkingGateway.php

Line Number: 57

Backtrace:

File: /var/www/html/sery_new/application/controllers/Admin.php Line: 3259 Function: sendMessage

File: /var/www/html/sery_new/index.php Line: 315 Function: require_once