Php Clickatell API将成功发送消息,但我无法接收消息
我正在测试Clickatell API,以便在我基于php的应用程序中集成SMS确认,我使用了他们的rest API将消息发送给我自己进行测试,但消息从未到达 我的尝试 我用它来检查覆盖率,这是JSON响应:Php Clickatell API将成功发送消息,但我无法接收消息,php,api,clickatell,Php,Api,Clickatell,我正在测试Clickatell API,以便在我基于php的应用程序中集成SMS确认,我使用了他们的rest API将消息发送给我自己进行测试,但消息从未到达 我的尝试 我用它来检查覆盖率,这是JSON响应: object(stdClass)[54] public 'data' => object(stdClass)[57] public 'routable' => boolean true public 'destination' =>
object(stdClass)[54]
public 'data' =>
object(stdClass)[57]
public 'routable' => boolean true
public 'destination' => string ' 21655609125' (length=12)
public 'minimumCharge' => float 0.8
object(stdClass)[54]
public 'data' =>
object(stdClass)[57]
public 'charge' => float 0.8
public 'messageStatus' => string '004' (length=3)
public 'description' => string 'Received by recipient' (length=21)
public 'apiMessageId' => string 'b57f4a28dece65a134b56be2010c8a78' (length=32)
public 'clientMessageId' => string '' (length=0)
我还通过检查状态来确保消息实际发送;这就是JSON响应:
object(stdClass)[54]
public 'data' =>
object(stdClass)[57]
public 'routable' => boolean true
public 'destination' => string ' 21655609125' (length=12)
public 'minimumCharge' => float 0.8
object(stdClass)[54]
public 'data' =>
object(stdClass)[57]
public 'charge' => float 0.8
public 'messageStatus' => string '004' (length=3)
public 'description' => string 'Received by recipient' (length=21)
public 'apiMessageId' => string 'b57f4a28dece65a134b56be2010c8a78' (length=32)
public 'clientMessageId' => string '' (length=0)
然后我在他们自己的网站上尝试发送消息和报告,这就是我看到的:
邮件内容感谢您测试Clickatell的网关覆盖率。你
将能够更改您的邮件内容后,您的初始
购买信息信用卡
突尼斯移动网络:橙色至21655609125
收件人收到(状态4)
但是我自己从来没有收到过这个信息。可能是什么问题
编辑:这是我目前在应用程序中使用的完整类
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
/**
* MC_SMS class
*/
class MC_SMS {
public $rest_uri = 'https://api.clickatell.com/rest';
public $method = 'post';
public $args = array();
/**
* Constructor
*/
public function __construct( $action, $data = null ) {
$this->data = $data;
$this->init();
switch( $action ) :
// Send message
case 'send' :
$this->endpoint = '/message';
$this->method = 'post';
break;
// Message status
case 'status' :
$this->endpoint = '/message/' . $data;
$this->method = 'get';
break;
// Network coverage
case 'coverage' :
$this->endpoint = '/coverage/' . $data;
$this->method = 'get';
break;
// Account balance
case 'balance' :
$this->endpoint = '/account/balance';
$this->method = 'get';
break;
endswitch;
$this->queried_uri = $this->rest_uri . $this->endpoint;
$this->do_request();
$this->response = ( isset( $this->response_body['body'] ) ) ? json_decode( $this->response_body['body'] ) : null;
}
/**
* Init.
*/
public function init() {
$this->headers = array(
'X-Version' => 1,
'Authorization' => 'Bearer ClHrbIEo_LwAlSVTSMemBIA5Gmvz8HNb5sio3N9GVDdAO_PPJPaZKzdi8Y8cDSmrs4A4',
'Content-Type' => 'application/json',
'Accept' => 'application/json'
);
$this->data = ( ! empty( $this->data ) && is_array( $this->data ) ) ? json_encode( $this->data ) : null;
$this->args['headers'] = $this->headers;
if ( $this->data ) {
$this->args['body'] = $this->data;
}
}
/**
* Do the API request
*/
public function do_request() {
if ( $this->method == 'get' ) {
$this->response_body = wp_remote_get( $this->queried_uri, $this->args );
}
if ( $this->method == 'post' ) {
$this->response_body = wp_remote_post( $this->queried_uri, $this->args );
}
}
}
付款前和使用试用积分时,您收到的信息是:
邮件内容感谢您测试Clickatell的网关覆盖率。您将能够在首次购买邮件信用后更改邮件内容
这意味着您已成功向设备发送和接收短信。只有在您支付信用卡后,收件人设备才会看到您自己的实际邮件。作为一个看起来正确的扩展,强调(我的):
您可以使用“日常任务”一章中列出的方法开始测试网关。但是,请注意,如果您使用的是帐户附带的10条免费短信积分,在您购买积分之前,Clickatell会将内容替换为感谢短信,如下面的消息所示:
感谢您测试Clickatell的网关覆盖率。您将能够在首次购买邮件信用后更改邮件内容
你为帐户付费了吗?还没有:)我只是用测试积分测试它,以决定它是否适用于我的应用程序。发布你实际用来发送消息的代码我发布了处理所有请求的整个类。我这样做是为了发送消息:$msg=newSMS('send',array('to'=>array('mynumber'),'text'=>testmsg');