Comments (10)
Don't json encode the values.
$container = [];
$email = ['name' => 'Loïc Vernet', 'email' => '[email protected]'];
$container['textContent'] = 'Hello world !';
$container['subject'] = 'SendinBlue test via V3 PHP API';
$container['sender'] = new SendSmtpEmailSender($email);
$container['replyTo'] = new SendSmtpEmailReplyTo($email);
$container['to'] = [$email];
$container['tags'] = ['test'];
$sendSmtpEmail = new SendSmtpEmail($container);
return $this->smtpApi->sendTransacEmail($sendSmtpEmail);
from apiv3-php-library.
AMEN.
For those who want to pass parameters in templates. The correct syntax is :
- Pass parameters in the form of array in PHP : ['VARIABLE' => 'test variable']
- Get the variable with {{ params.VARIABLE }}
DO NOT use % % in templates for parameters.
Note to sendinblue : I had to pass through hell just for that, finally finding the solution thanks to retrieving html templates with conditions on parameters and reading this : https://help.sendinblue.com/hc/fr/articles/360000591660
from apiv3-php-library.
Hi,
You're welcome !
For your second question, If I understand well, you want to use "contact" datas without creating a contact. I don't think it's possible unless passing the parameters like you said before params.FIRSTNAME. This is the way you're looking for since you want to get the firstname directly from your database.
Also for your information, I think that a contact may be automatically created by Sendinblue when you send an email but I don't know how does Sendinblue get the firstname and lastname in the automatic process.
from apiv3-php-library.
As reference for further investigation, here is something useful: https://github.com/sendgrid/sendgrid-php
from apiv3-php-library.
Sendgrid PHP API quality was also low some times ago, it's better now.
But +1 for the doc. For example for the sendtransacemail
function doc :
$sendSmtpEmail = new \SendinBlue\Client\Model\SendSmtpEmail(); // \SendinBlue\Client\Model\SendSmtpEmail | Values to send a transactional email
try {
$result = $apiInstance->sendTransacEmail($sendSmtpEmail);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling SMTPApi->sendTransacEmail: ', $e->getMessage(), PHP_EOL;
}
It's not real code as SendSmtpEmail is created without argument. Such a code leads to an error 400 :
Client error: `POST https://api.sendinblue.com/v3/smtp/email` resulted in a `400 Bad Request` response:
{"code":"missing_parameter","message":"No input in body"}
I had to figure out how to pass the to parameter as the documentation is no correct. In fact "Models" sometimes seem not to have to be used ! 🤔
from apiv3-php-library.
Hi @COil,
How did you pass the parameters (i'm fighting with json types that are refused by Sendinblue).
My current code :
$params[] = json_encode(array( 'TITLE' => 'testtitle', 'TITLE2' => 'testtitle' )); $sendSmtpEmail->setParams($params);
It doesn't work. Sendinblue log write :
"build template args: decode: json: cannot unmarshal array into Go struct field httpRequestTemplateArgs.params of type map[string]interface {}\n"
I'm stuck with it and i would love a little help. Btw I agree with the fact that documentation is very poor...
Thank you :-)
from apiv3-php-library.
Thank you very much !
Unfortunately I dont succeed in using my params in my template even without json_encoding.
%VARIABLE%
is not replaced by my params set by $container['params'] = ['VARIABLE' => 'test variable']
I'm trying to reach the tech support
from apiv3-php-library.
Hi @vcopleutre! Your comment is a life-saver!
Did you maybe find out how to use {{ contact.FIRSTNAME }}
"transactionally"? I mean I'd like to pass the user name on the fly from my database, without a necessity of creating a contact in Sendinblue. Is there any special way to pass the contact
data or I just should use {{ params.FIRSTNAME }}
?
from apiv3-php-library.
I went with the solution with {{ params.FIRSTNAME }}
as I trust more data in my database than something automatically created by Sendinblue.
Another important thing: you cannot use hyphens '-' in the variable names. So {{ params.FIRST_NAME }}
will work properly, but {{ params.FIRST-NAME }}
will fail.
For those working in Laravel with Sendinblue, I have extended the https://github.com/agence-webup/laravel-sendinblue library for using the Sendinblue templates and transactional parameters (agence-webup/laravel-sendinblue#43).
from apiv3-php-library.
Hi,
Can you please tell, do you still face issues with the documentation part in order to use it, if yes can you please share where you are facing issues? So that we can check and improve it, as its an old thread we have changed a lot in our documentation from then.
Thanks!
from apiv3-php-library.
Related Issues (20)
- php 8.1 compatibility HOT 7
- Sales CRM - companies and deals HOT 1
- Webhooks API: getWebhook throws: Invalid value for 'type', must be one of 'marketing', 'transac' HOT 2
- Difficulties to install API v3 HOT 3
- Problems with the package HOT 1
- Multiple recipients only sends to last in array HOT 1
- SendinBlue\Client\Configuration" not found HOT 2
- Issue about removeContactFromList api HOT 1
- createDoiContact throws exception with "This sms number or email address is already associated with another user" for blacklisted users
- How can we set preview text of email campaign
- GetEmailCampaigns & new parameter HOT 4
- Create Or Update Contact with unlinkListIds HOT 1
- ContactsAPI updateBatchContacts results in 404 when one of emails not found HOT 1
- Missing domain managements routes in the SDK HOT 2
- Error "message":"to is not valid in messageVersions"
- Brevo API Endpoint migration HOT 3
- Guzzle Error with SDK 8.4.2 & php 7.4.3 HOT 1
- ContactsAPI Unable to create a list
- getContactsInfo without statistics?
- Send test template is there, but send template is not (on the smtpclient)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apiv3-php-library.