无法使用php中的plvo令牌和auth id获取或显示收到的SMS [英] Unable to get or display received sms using plivo token and auth id in php

查看:68
本文介绍了无法使用php中的plvo令牌和auth id获取或显示收到的SMS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理PHP脚本,我想在其中获取并显示在Plivo号码上收到的所有消息?

我已经尝试了两种不同的方法,但都不起作用

请指导我如何获得方法1中必需的your_message_uuid

方法1

require 'vendor/autoload.php';
use PlivoRestClient;

$client = new RestClient("auth id", "auth_token");
$response = $client->messages->get('your_message_uuid');
print_r($response);

方法2

require 'vendor/autoload.php';
use PlivoRestClient;

$client = new RestClient("auth id", "auth_token");
$response = $client->messages->list(
    [
        'limit' => 5,
        'offset' => 0,
        'subaccount' =>'subaccount_auth_id'
    ]
);
print_r($response);
// Prints only the message_uuid
print_r($response->getmessageUuid(0));

使用方法1的结果

PlivoResourcesMessageMessage Object ( [client:protected] => PlivoBaseClient Object ( [timeout:protected] => [httpClientHandler:protected] => PlivoHttpClientsPlivoGuzzleHttpClient Object ( [guzzleClient:protected] => GuzzleHttpClient Object ( [config:GuzzleHttpClient:private] => Array ( [handler] => GuzzleHttpHandlerStack Object ( [handler:GuzzleHttpHandlerStack:private] => Closure Object ( [static] => Array ( [default] => GuzzleHttpHandlerCurlMultiHandler Object ( [factory:GuzzleHttpHandlerCurlMultiHandler:private] => GuzzleHttpHandlerCurlFactory Object ( [handles:GuzzleHttpHandlerCurlFactory:private] => Array ( ) [maxHandles:GuzzleHttpHandlerCurlFactory:private] => 50 ) [selectTimeout:GuzzleHttpHandlerCurlMultiHandler:private] => 1 [active:GuzzleHttpHandlerCurlMultiHandler:private] => [handles:GuzzleHttpHandlerCurlMultiHandler:private] => Array ( ) [delays:GuzzleHttpHandlerCurlMultiHandler:private] => Array ( ) [options:GuzzleHttpHandlerCurlMultiHandler:private] => Array ( ) ) [sync] => GuzzleHttpHandlerCurlHandler Object ( [factory:GuzzleHttpHandlerCurlHandler:private] => GuzzleHttpHandlerCurlFactory Object ( [handles:GuzzleHttpHandlerCurlFactory:private] => Array ( [0] => Resource id #55 ) [maxHandles:GuzzleHttpHandlerCurlFactory:private] => 3 ) ) ) [parameter] => Array ( [$request] => [$options] => ) ) [stack:GuzzleHttpHandlerStack:private] => Array ( [0] => Array ( [0] => Closure Object ( [parameter] => Array ( [$handler] => ) ) [1] => http_errors ) [1] => Array ( [0] => Closure Object ( [parameter] => Array ( [$handler] => ) ) [1] => allow_redirects ) [2] => Array ( [0] => Closure Object ( [parameter] => Array ( [$handler] => ) ) [1] => cookies ) [3] => Array ( [0] => Closure Object ( [parameter] => Array ( [$handler] => ) ) [1] => prepare_body ) ) [cached:GuzzleHttpHandlerStack:private] => Closure Object ( [static] => Array ( [handler] => GuzzleHttpRedirectMiddleware Object ( [nextHandler:GuzzleHttpRedirectMiddleware:private] => Closure Object ( [static] => Array ( [handler] => GuzzleHttpPrepareBodyMiddleware Object ( [nextHandler:GuzzleHttpPrepareBodyMiddleware:private] => Closure Object ( [static] => Array ( [default] => GuzzleHttpHandlerCurlMultiHandler Object ( [factory:GuzzleHttpHandlerCurlMultiHandler:private] => GuzzleHttpHandlerCurlFactory Object ( [handles:GuzzleHttpHandlerCurlFactory:private] => Array ( ) [maxHandles:GuzzleHttpHandlerCurlFactory:private] => 50 ) [selectTimeout:GuzzleHttpHandlerCurlMultiHandler:private] => 1 [active:GuzzleHttpHandlerCurlMultiHandler:private] => [handles:GuzzleHttpHandlerCurlMultiHandler:private] => Array ( ) [delays:GuzzleHttpHandlerCurlMultiHandler:private] => Array ( ) [options:GuzzleHttpHandlerCurlMultiHandler:private] => Array ( ) ) [sync] => GuzzleHttpHandlerCurlHandler Object ( [factory:GuzzleHttpHandlerCurlHandler:private] => GuzzleHttpHandlerCurlFactory Object ( [handles:GuzzleHttpHandlerCurlFactory:private] => Array ( [0] => Resource id #55 ) [maxHandles:GuzzleHttpHandlerCurlFactory:private] => 3 ) ) ) [parameter] => Array ( [$request] => [$options] => ) ) ) ) [parameter] => Array ( [$request] => [$options] => ) ) ) ) [parameter] => Array ( [$request] => [$options] => ) ) ) [allow_redirects] => Array ( [max] => 5 [protocols] => Array ( [0] => http [1] => https ) [strict] => [referer] => [track_redirects] => ) [http_errors] => 1 [decode_content] => 1 [verify] => 1 [cookies] => [idn_conversion] => 1 [headers] => Array ( [User-Agent] => GuzzleHttp/6.5.5 curl/7.75.0 PHP/7.2.34 ) ) ) [authId:protected] =>  [authToken:protected] =>  ) [basicAuth:protected] => PlivoAuthenticationBasicAuth Object ( [authId:protected] => [authToken:protected] => ) ) [interface:protected] => [id:protected] => [pathParams:protected] => Array ( [authId] => [messageUuid] => ) [properties] => Array ( [from] => [to] => [messageDirection] => [messageState] => [messageTime] => [messageType] => [messageUuid] => [resourceUri] => [totalAmount] => [totalRate] => [units] => ) )

使用方法2的结果为空

推荐答案

签出Plivo's use case guide to receiving SMS messages。它解释了如何

  1. 创建PHP应用程序以读取消息内容
  2. 创建Plivo短信应用并为其分配PHP应用
  3. 将Plivo SMS应用程序分配给Plivo号码(将收到 传入短信)
  4. 每当在该Plivo号码上接收到传入SMS消息时,Plivo 会将详细信息发送到他在Plivo SMS中配置的应用程序服务器 APP(消息URL)

这篇关于无法使用php中的plvo令牌和auth id获取或显示收到的SMS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆