Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation is very poor, bis! #70

Open
haterecoil opened this issue Jan 31, 2019 · 10 comments
Open

Documentation is very poor, bis! #70

haterecoil opened this issue Jan 31, 2019 · 10 comments

Comments

@haterecoil
Copy link

Dear maintainers,

What the hell? The PHP library is both poorly designed and poorly documented.

PS: this is a product we are paying for. As of 2019 a SDK is the bare minimum you could provide. FYI here is the pricing page of SendinBlue : https://account.sendinblue.com/pricing/

@haterecoil
Copy link
Author

As reference for further investigation, here is something useful: https://github.com/sendgrid/sendgrid-php

@COil
Copy link

COil commented Apr 12, 2019

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 ! 🤔

@vcopleutre
Copy link

vcopleutre commented Apr 23, 2019

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 :-)

@COil
Copy link

COil commented Apr 23, 2019

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);

@vcopleutre
Copy link

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

@vcopleutre
Copy link

vcopleutre commented Apr 23, 2019

AMEN.
For those who want to pass parameters in templates. The correct syntax is :

  1. Pass parameters in the form of array in PHP : ['VARIABLE' => 'test variable']
  2. 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

@boryn
Copy link

boryn commented Aug 25, 2021

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 }}?

@vcopleutre
Copy link

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.

@boryn
Copy link

boryn commented Nov 3, 2021

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).

@preetishishodia7
Copy link
Contributor

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants