未授权端点,请检查设置->安全->远程站点设置端点 [英] Unauthorized endpoint, please check Setup->Security->Remote site settings endpoint

查看:57
本文介绍了未授权端点,请检查设置->安全->远程站点设置端点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法通过 Twilio API 发送短信.我得到以下异常:

I'm unable to send an SMS via Twilio API. I got the exception below:

错误:未授权端点,请检查设置->安全->远程站点设置端点:url

ERROR : Unauthorized endpoint, please check Setup->Security->Remote site settings endpoint: url

global class SampleSMSTest {
    @future(callout=true)
    public static void testsms() {
        try {
            String account = 'xxxxxxxxx';
            String token = 'xxxxxxxxxx';
            TwilioRestClient client = new TwilioRestClient(account, token);
            Map<String, String> params = new Map<String, String> {
                'To' => '+91953835xxxx',
                'From' => '+1920569xxxx', // twilio registered number
                'Body' => 'Hello there!'
            };
            TwilioMessage message = client.getAccount().getMessages().create(params);
        } catch (Exception e) {
            System.debug('Main error==========>' + e);
        }
    }
}

推荐答案

这看起来像 Salesforce APEX 代码.无论何时您想要从 Salesforce 调用外部 URL,您都需要将该 URL 设置为安全的远程站点.错误消息会告诉您在 SF 中的确切位置.将 Twilio URLapi.twilio.com"添加到列表中.

This looks like Salesforce APEX code. Anytime you want to call an external URL from Salesforce, you need to set the URL as a safe remote site. The error message tells you exactly where to go in SF. Add the Twilio URL "api.twilio.com" to the list.

这篇关于未授权端点,请检查设置->安全->远程站点设置端点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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