smsgatewayme / client-php

PHP Client for smsgateway.me
26 stars 32 forks source link

Callback parameters #2

Open sadiqumar18 opened 6 years ago

sadiqumar18 commented 6 years ago

Please I want to know what parameters do the callback URL contains

hicarocastro commented 6 years ago

what a pity, you changed everything and it's impossible to make it work like funcinonava before!

I had a simple schedule like this and now I'm completely lost

<?php

include "smsGateway.php"
$smsGateway = new SmsGateway('demo@smsgateway.me', 'password');

$deviceID = 1;
$number = '+44771232343';
$message = 'Hello World!';

$result = $smsGateway->sendMessageToNumber($number, $message, $deviceID);
sadiqumar18 commented 6 years ago

The V4 is good. Only that you need to tweak something's

hicarocastro commented 6 years ago

The problem is this, because the system now seems to be totally different. There are no simple examples in PHP

hicarocastro commented 6 years ago

including the homepage is saying a untruth https://screenpresso.com/=Dr22e

louiedgomez commented 6 years ago

I've already converted the PHP client to C# now its no longer working, also how do you use the api key? i'm trying to do it in PostMan but does not work.

louiedgomez commented 6 years ago

@sadiqumar18 what do yo need to tweak? I had to change everything for V4.

sadiqumar18 commented 6 years ago

try using resteasy. It will work

sadiqumar18 commented 6 years ago

I rest easy add header with Authorization with value= < your api>

louiedgomez commented 6 years ago

@sadiqumar18 Thanks I will try that I was using Restsharp.

emres120 commented 6 years ago

Hello, Can you make a simple file for send sms and other function. Thank you

emres120 commented 6 years ago

like before

JuniYadi commented 6 years ago

i think you should look up on their documentation https://smsgateway.me/sms-api-documentation/getting-started

emres120 commented 6 years ago

Can you give me a code for work with old code ! Because my site not working with this code.

emres120 commented 6 years ago

In this format

include "smsGateway.php"
$smsGateway = new SmsGateway('demo@smsgateway.me', 'password');

$deviceID = 1;
$number = '+44771232343';
$message = 'Hello World!';

$result = $smsGateway->sendMessageToNumber($number, $message, $deviceID);
JuniYadi commented 6 years ago

i think, you should update to new api v4 lookup here the example very clear https://smsgateway.me/sms-api-documentation/messages/sending-a-sms-message

louiedgomez commented 6 years ago

I'm having a problem making this code work specifically the add header token part, I'm using Restsharp, I convert the old smsgateway client to c#

private string MakeRequest(string url, Method method, Dictionary<string, string> fields) { url = $"{_baseUrl}/{url}";

        var client = new RestClient(url);

        _request = new RestRequest(url, method);
        _request.AddParameter("Authorization", _token, ParameterType.HttpHeader);

        foreach (var item in fields)
        {
            _request.AddParameter(item.Key, item.Value,  ParameterType.UrlSegment);
        }

        IRestResponse response = client.Execute(_request);
        return response.Content;

    }
sadiqumar18 commented 6 years ago

They seems to be problem with the version 4, I have been trying to send message but it is not working. But it works well on postman

shahfaisalahmad commented 6 years ago

I tried using postman. It seems, their apikey is changing everytime.Could you please provide the detail, how did you send using postman?

sadiqumar18 commented 6 years ago

screenshot 27 screenshot 28

sadiqumar18 commented 6 years ago

I dont think the api key changes, I have been using one since

Ludplay commented 6 years ago

Thanks, sadiqumar18. These screenshots were very helpfull. I could make it work in postman. But no success with PHP code.

My code always return exception "timed out". No matter what operation (sendMessage, callback, getMessage) it is.

What error are you guys facing?

shahfaisalahmad commented 6 years ago

Thanks for your immediate response but I'm still getting error. Please find screen shot below.

error

error2

Are you getting API Token from Account -> setting ? Every time when I go to setting, I'm getting new API Token.

error3

sadiqumar18 commented 6 years ago

@shahfaisalahmad I think your own error is base on the change in api key

sadiqumar18 commented 6 years ago

@ludplay in postman,by the right hand side check click on code,then generate php curl code. I think that should work. But as for me I couldn't send a message with it

shahfaisalahmad commented 6 years ago

It seems, I can't get response because my APIKey is updating on every time. :

savifon commented 6 years ago

I'm using the documentation code, just changing the token and phone number and device id.

<?php

require 'autoload.php';

use SMSGatewayMe\Client\ApiClient;
use SMSGatewayMe\Client\Configuration;
use SMSGatewayMe\Client\Api\MessageApi;
use SMSGatewayMe\Client\Model\SendMessageRequest;

// Configure client
$config = Configuration::getDefaultConfiguration();
$config->setApiKey('Authorization', 'TOKEN');
$apiClient = new ApiClient($config);
$messageClient = new MessageApi($apiClient);

// Sending a SMS Message
$sendMessageRequest1 = new SendMessageRequest([
    'phoneNumber' => 'PHONE NUMBER',
    'message' => 'test1',
    'deviceId' => ID DEVICE
]);
$sendMessageRequest2 = new SendMessageRequest([
    'phoneNumber' => 'PHONE NUMBER',
    'message' => 'test2',
    'deviceId' => ID DEVICE
]);
$sendMessages = $messageClient->sendMessages([
    $sendMessageRequest1,
    $sendMessageRequest2
]);
print_r($sendMessages);
?>

The following error is returned:

Fatal error: Uncaught SMSGatewayMe\Client\ApiException: API call to https://smsgateway.me/api/v4/message/send timed out: a:26:{s:3:"url";s:41:"https://smsgateway.me/api/v4/message/send";s:12:"content_type";N;s:9:"http_code";i:0;s:11:"header_size";i:0;s:12:"request_size";i:0;s:8:"filetime";i:-1;s:17:"ssl_verify_result";i:1;s:14:"redirect_count";i:0;s:10:"total_time";d:0.25;s:15:"namelookup_time";d:9.9999999999999995E-7;s:12:"connect_time";d:0.25;s:16:"pretransfer_time";d:0;s:11:"size_upload";d:0;s:13:"size_download";d:0;s:14:"speed_download";d:0;s:12:"speed_upload";d:0;s:23:"download_content_length";d:-1;s:21:"upload_content_length";d:-1;s:18:"starttransfer_time";d:0;s:13:"redirect_time";d:0;s:12:"redirect_url";s:0:"";s:10:"primary_ip";s:13:"54.229.39.139";s:8:"certinfo";a:0:{}s:12:"primary_port";i:443;s:8:"local_ip";s:15:"186.202.119.229";s:10:"local_port";i:49643;} in E:\Vhosts\painell.com\httpdocs\testesmssavio\lib\ApiClient.php:230 Stack trace: #0 E:\Vhosts\painell.com\httpdocs\testesmssavio\lib\Api\MessageApi.php(525) in E:\Vhosts\painell.com\httpdocs\testesmssavio\lib\ApiClient.php on line 230

And it does not have in the documentation the adjustments that we must make in the previous version to work correctly.

Ludplay commented 6 years ago

@savifon same here. I think we need to open a issue about it. I'm gonna do it.

sadiqumar18 commented 6 years ago

Try getting your device info it should work, the problem is it doesn't work when you try to send message.

Ludplay commented 6 years ago

@sadiqumar18 Were you capable to get device info? May you post your code here? Because, in my case, whatever I request my response is exactly as @savifon's

louiedgomez commented 6 years ago

I think its the same for me too, every time I click settings it change the api key.

Ludplay commented 6 years ago

@sadiqumar18 thanks again. Your instructions to generate php curl code from postman were very helpful. I could send message from it. With the code generated, you might get the 'SSL verify error'. So, before curl_exec line, put line curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); Message sent here. I think I will go with endpoint at least until this new php class v4 is corrected.

Ludplay commented 6 years ago

@gmcit and @shahfaisalahmad , these api key changes also happens to me. But just ignore it. Use the first you generate and go with it. I thought this was a problem too (maybe it is a problem), but I could use any of the keys generated.

@shahfaisalahmad about your failed request in postman, was it not for the '[' missing in your code? The structure is: [ { "phone_number": "+00649169194", "message": "Hello World", "device_id": 00000 } ]

sadiqumar18 commented 6 years ago

@Ludplay please can you send us screen shots of your code, i am still having problem sending message thanks

sadiqumar18 commented 6 years ago

The code works on my localhost server but not on remote server

Ludplay commented 6 years ago

I didn't try it on remote server either. But, on localhost, works perfectly. I'm already creating a class to work similar v3 smsGateway Class. But, to help you since now, take a look at this code.

$array_fields['phone_number'] = '+00226497491';
$array_fields['message'] = 'Test';
$array_fields['device_id'] = 00000;

$token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOxxxxxxxxxxxxxxxxxxxxxxx";

$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://smsgateway.me/api/v4/message/send",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_POSTFIELDS => "[  " . json_encode($array_fields) . "]",
    CURLOPT_HTTPHEADER => array(
        "authorization: $token",
        "cache-control: no-cache"
    ),
));
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
    echo "cURL Error #:" . $err;
} else {
    echo $response;
}
muhammadyounispk commented 6 years ago

Who is Using Smsgateway.me Currently with Api v4 answer us please?

savifon commented 6 years ago

@Ludplay your code worked.!!!

sadiqumar18 commented 6 years ago

mine is working both on locally and remotely, wheeeew a problem shared is a problem solved thanks to each and everyone here. If you are still having any problem feel free to reach out..the code from @Ludplay is all you need for a start. @Ludplay let me know when you are done with the implementation...Thanks

sadiqumar18 commented 6 years ago

Before i forget has anyone here used the callback from the api, i would like to know what parameters are been sent by the api.

Ludplay commented 6 years ago

I've created a class similar to v3. Hope it helps. https://github.com/Ludplay/smsgatewayme-php-endpoint

sadiqumar18 commented 6 years ago

I like the way you leave the email and password

shahfaisalahmad commented 6 years ago

Thanks for your help. You are correct. APIKey is keep changing but If I'm taking any of the APIKey & posting request using POSTMAN. It's working. Only problem was JSON format. I have written JAVA API to post the request. It's working. Let me know if anyone need. I will share.

sadiqumar18 commented 6 years ago

Feel free to drop your repo @shahfaisalahmad

ashhadsheikh commented 6 years ago

Here's a ruby gem for this API, in case if anyone is interested in using it in Rails or other Application.

louiedgomez commented 6 years ago

My code works both for remote and local. however it seems that the smsgateway.me site has problems I can create a new account it only says registering... does anyone encounter the same?

louiedgomez commented 6 years ago

@Ludplay

I also created a similar version in .net using restsharp, will post it soon for others using .net core framework

louiedgomez commented 6 years ago

Don't you think there should also be an Add Device, so we can remotely add devices to SMS Gateway.

louiedgomez commented 6 years ago

@PanwarInformationTechnology I'm using V4