Php curl api对短信没有给出回应

时间:2018-04-06 08:34:12

标签: php curl

<i><?php
    $apiKey = urlencode('ym4qoK7ier4-ekRPruxP1eqh0pPHsn9slaivPpMtZY');
    $numbers = array(917823466910, 918790650519);
    $sender = urlencode('Garry');
    $message = rawurlencode('This is your message');
    $numbers = implode(',', $numbers);
    $data = array('apikey' => $apiKey, 'numbers' => $numbers, "sender" =>    $sender, "message" => $message);
    $ch = curl_init('https://api.textlocal.in/send/');
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
    echo $response = curl_exec($ch);
    curl_close($ch);
    echo $response;
?></i>

没有响应正在执行,也没有通过手机收到任何消息

1 个答案:

答案 0 :(得分:0)

TextLocal期望参数usernamehashmessagesendernumbers,如果您的帐户是测试,那么需要通过test太像这样

$data = "username=".$username."&hash=".$hash."&message=".$message."&sender=".$sender."&numbers=".$numbers."&test=".$test;