簡體   English   中英

如何在php中發送短信?

[英]How send sms in php?

我該如何解決這個問題? 我無法在工作中發送短信。

$ch = curl_init(); //curl()
$parameters = array(
  'apikey' => '8a6bb687750b59d8f099cb489b43c256', //Your API KEY
  'number' => '09096817174',//number
  'message' => 'I just sent my first message with Semaphore', //message
  'sendername' => 'SEMAPHORE');
curl_setopt( $ch, CURLOPT_URL,'https://semaphore.co/api/v4/messages');
curl_setopt( $ch, CURLOPT_POST, 1 );

//Send the parameters set above with the request
curl_setopt( $ch, CURLOPT_POSTFIELDS, http_build_query( $parameters ) );

我該如何解決這個問題? 我在信號量中有我的 apikey。

嘿,我試過這段代碼並打印輸出

    <?php
// Generated by curl-to-PHP: http://incarnate.github.io/curl-to-php/
$ch = curl_init();

$ch = curl_init();
$parameters = array(
    'apikey' => '8a6bb687750b59d8f099cb489b43c256', //Your API KEY
    'number' => '0987654321',//for testing no 
    'message' => 'I just sent my first message with Semaphore',
    'sendername' => 'SEMAPHORE'
);
curl_setopt( $ch, CURLOPT_URL,'https://semaphore.co/api/v4/messages' );
curl_setopt( $ch, CURLOPT_POST, 1 );

//Send the parameters set above with the request
curl_setopt( $ch, CURLOPT_POSTFIELDS, http_build_query( $parameters ) );

// Receive response from server
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
$output = curl_exec( $ch );
curl_close ($ch);

//Show the server response

echo $output;

我得到了返回輸出

"message_id":73840803,

"status":"Pending",

使用實時密鑰和測試並嘗試點擊相同的代碼檢查狀態等待接收

這對我有用

 $ch = curl_init(); 
 $parameters = array(
          'apikey' => '8a6bb687750b59d8f099cb489b43c256', 
          'number' => '9000000000',
          'message' => 'I just sent my first message with Semaphore', 
          'sendername' => 'SEMAPHORE'
          );
curl_setopt( $ch, CURLOPT_URL,'https://semaphore.co/api/v4/messages' );
curl_setopt( $ch, CURLOPT_POST, 1 );
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

//Send the parameters set above with the request
curl_setopt( $ch, CURLOPT_POSTFIELDS, http_build_query( $parameters ) );

$result = curl_exec($ch);
print_r($result);
if (curl_errno($ch)) {
    $error_msg = curl_error($ch);
    print_r($error_msg);
}
curl_close($ch);
exit;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM