如何在 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;
我得到了 return 输出
"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;
如何解决这个问题?我无法发送有关工作的短信。
$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;
我得到了 return 输出
"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;