mysms api 登录并获取短信

问题描述 投票:0回答:1

我正在开发一个程序,能够使用MySMS发送和接收短信。 我有 API 密钥,并且我设法编写了发送短信的代码。 但我在尝试登录 api 并获取短信时遇到问题。我正在使用 Postman,当我尝试登录时,它给我响应代码 500。

https://api.mysms.com/rest/user/login

关于我做错了什么的任何线索,我的所有数据都是正确的,但我不确定格式或任何其他事情。

image explaining the parameters and documentation and the response code

api sms
1个回答
0
投票
       $url      = 'https://api.mysms.com/json/user/login';
      $mydata  = array(
                        'apiKey'   => $apikey,
                        'msisdn'   => $msisdn,
                        'password' => $password,
                        
                    );
    $post_data = json_encode($mydata);
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
    $headers = array();
    $headers[] = 'Content-Type: application/json';
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    $result = curl_exec($ch);
    if (curl_errno($ch)) {
        echo 'Error:' . curl_error($ch);
    }
    curl_close($ch);
    return $result;
© www.soinside.com 2019 - 2024. All rights reserved.