在我的Ruby on Rails应用程序中,我一直收到这样的错误:"757:意外的令牌‘无法验证您对该URL的访问级别。您必须使用正确的凭据登录“。
代码如下:
def send_message_plivo
p = RestAPI.new(ENV["PLIVO_AUTHID"], ENV["PLIVO_AUTHTOKEN"])
params = {
"src" => "1111111111",
"dest" => "xxxxxxxxxxxxx", # <- my only verified number
"text" => "Hi! From Plivo",
"url" => "http://localhost:3000/sent_message_status",
"method" => "POST"
}
response = p.send_message(params) # <- line of the error!
puts response
end你知道我错过了什么吗?
发布于 2016-03-16 02:04:15
根据plivo.com/docs/api/message,参数应该是"dst“而不是"dest”。
此外,请仔细检查您的Plivo Auth ID和Auth Token所使用的值。确保您使用的是您的身份验证ID (20左右的“随机”字符串),而不是您的Plivo用户名。
发布于 2016-05-17 16:24:30
你必须这样做:
$auth_id = 'PLIVO_AUTHID';
$auth_token = 'PLIVO_AUTHTOKEN';
$p = new RestAPI($auth_id, $auth_token);
// Set message parameters
$params = array(
'src' => '1111111111', // Sender's phone number with country code
'dst' => '2222222222', // Receiver's phone number with country code
'text' => 'Hi, Message from Plivo', // Your SMS text message
//'url' => 'http://example.com/report/', // The URL to which with the status of the message is sent
'method' => 'GET' // The method used to call the url
);
// Send message
$response = $p->send_message($params);
// Print the response
echo "Response : ";
print_r ($response['response']);
// Print the Api ID
echo "<br> Api ID : {$response['response']['api_id']} <br>";
// Print the Message UUID
echo "Message UUID : {$response['response']['message_uuid'][0]} <br>";如果你得到这样的响应:-
Response : Array ( [api_id] => 2c5af359-1c06-11e6-8a00-22000ae28743 [message] => message(s) queued [message_uuid] => Array ( [0] => 0f2afda3-b869-45f6-9baf-13acc1992cb8 ) ) Api ID : 2c5af359-1c06-11e6-8a00-22000ae28743 Message UUID : 0f2afda3-b869-45f6-9baf-13acc1992cb8 这意味着您的消息已发送。
https://stackoverflow.com/questions/35983453
复制相似问题