【问题标题】:Can you use SendGrid's PHP v5.5.1 API with the username and password instead of API Key您可以使用带有用户名和密码而不是 API 密钥的 SendGrid 的 PHP v5.5.1 API
【发布时间】:2017-06-22 02:20:18
【问题描述】:

我有以下代码,我想与本地版本的 SendGrid 一起使用。唯一的问题是它不是我的密码。经过研究,我发现密码与 API Key 完全不同。我无法更新 API 密钥,因为更新时邮件不会在我的实时生产服务器上发送。

我本地的代码如下:

 <?php
require '../database/vendor/autoload.php';
// If you are not using Composer
// require("path/to/sendgrid-php/sendgrid-php.php");
$from = new SendGrid\Email(null, "test@test.com");
$subject = "Sending with SendGrid is Fun";
$to = new SendGrid\Email(null, "test@test.com");
$content = new SendGrid\Content("text/plain", "and easy to do anywhere, even with PHP");
$mail = new SendGrid\Mail($from, $subject, $to, $content);
//$apiKey = getenv('xxxxxx');
//$apiKey = "xxxxxx";
$sg = new \SendGrid("xxxxxx");
$response = $sg->client->mail()->send()->post($mail);
echo $response->statusCode();
print_r($response->headers());
echo $response->body();
?>

但是我不断收到以下错误:
提供的授权授权无效、过期或被撤销=

【问题讨论】:

  • 如果您的服务器现在不发送邮件,为什么不能更新到 API 密钥,然后它才能工作?
  • 我是说一旦我更新了 api 密钥,邮件将无法工作。但事实并非如此,因为我发现您可以创建多个 api 密钥。之后,挖掘和搜索,我发现因为我们运行的是 SendGrid 版本 1,所以我们一开始就没有 api 密钥。即使我们这样做了,您也可以创建多个彼此不冲突的 api 密钥。

标签: php api sendgrid


【解决方案1】:

我发现您可以创建多个 api 密钥。之后,挖掘和搜索,我发现因为我们运行的是 SendGrid 版本 1,所以我们一开始就没有 api 密钥。即使我们这样做了,您也可以创建多个彼此不冲突的 api 密钥。此外,您似乎仅在使用 SendGrid V3 之前的版本时才使用用户名和密码

【讨论】:

    猜你喜欢
    • 2015-03-27
    • 1970-01-01
    • 2019-05-22
    • 2022-06-15
    • 1970-01-01
    • 2020-11-02
    • 2016-04-09
    • 2020-07-26
    • 2019-01-30
    相关资源
    最近更新 更多