php - 如何在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",
使用实时密钥和测试并尝试达到相同的代码检查状态等待接收
推荐阅读
- r - 使用区间距离而不是单元距离连接来自不同组的异常区间
- scrum - 在 sprint 期间重新分配用户故事?
- c# - 为什么我们不能在 c# struct 的声明中初始化实例字段?
- python - 按元组的第一个元素对元组列表进行排序而不删除重复项
- java - 如何使用最新的 Eclipse 正确导入 java.awt?
- java - 执行 TestNG 套件后显示错误“java.lang.NullPointerException DefaultElementLocator.findElement(DefaultElementLocator.java:69)”
- git - 在 git 中为 Visual Studio 2019“导出”本地分支
- python - 根据python中的每日表删除每行的所有(每小时)日条目
- swift - 是否可以使用 URL 会话委托方法进行进度和完成处理程序来完成?还是更好的选择?
- java - 为什么 Exchange Web 服务 API 无法从邮箱中删除邮件?