admin管理员组文章数量:1336434
HTML Form Code
<form id="contactForm" action="contact.php" method="post" name="contactForm">
<div class="form-group">
<label for="name">Name</label>
<input id="name" class="form-control" name="name" type="text">
</div>
<div class="form-group">
<label for="email">Email</label>
<input id="email" class="form-control" name="email" type="email">
</div>
<div class="form-group">
<input class="btn btn-special" type="submit" value="Subscribe">
<div class="submitting"></div>
</div>
</form>
PHP Code
<?php
require 'vendor/autoload.php';
use \Mailjet\Resources;
$name = $_POST['name'];
$email = $_POST['email'];
$mj = new \Mailjet\Client(getenv('123'), getenv('123'), true, ['version' => 'v3']);
// `123` is a placeholder for demonstration.
$body = [
'Name' => $name,
'Properties' => "object",
'Action' => "addnoforce",
'Email' => $email
];
$response = $mj->post(Resources::$ContactslistManagecontact, ['id' => 1234, 'body' => $body]);
$response->success() && var_dump($response->getData());
var_dump($response->getData());
?>
I am following the official Mailjet API documentation example. However, I keep receiving the following empty response:
array(0) { }
What I've Tried
- Ensured the
vendor/autoload.php
file is correctly included. - Verified that
1234
(used in theid
parameter) corresponds to my Contacts List ID. - Used the official example from Mailjet's GitHub and checked for deprecated usage.
Despite spending hours troubleshooting, I am still unable to resolve this issue. I found this older reference, but it is outdated and doesn't align with the current Mailjet API version.
Questions:
- Is there an issue with my
ContactslistManagecontact
endpoint configuration? - Am I correctly passing the parameters for the API call?
- What could be the cause of the empty
array(0)
response, and how can I debug it further?
Reference Links:
- Mailjet API Documentation: Manage Contacts
- Mailjet GitHub Library
Any insights or solutions would be greatly appreciated!
本文标签: phpTrouble Adding a Contact to Mailjet via API array(0) ResponseStack Overflow
版权声明:本文标题:php - Trouble Adding a Contact to Mailjet via API: `array(0) { }` Response - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742312715a2451196.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论