Coder Social home page Coder Social logo

Comments (12)

bjornbos avatar bjornbos commented on July 17, 2024 4

I just ditched the PHP SDK and use the REST api directly. Works so much better.

from apiv3-php-library.

ekta-slit avatar ekta-slit commented on July 17, 2024

Hello @pirmax

FYI please update the library as we have done some minor fixes.
After that for create contact API I suggest you to use below sample code:

Sendinblue\Client\Configuration::getDefaultConfiguration()->setApiKey('api-key', env('SENDINBLUE_API_KEY'));

$api_instance = new Sendinblue\Client\Api\ContactsApi();
$create_contact = new \Sendinblue\Client\Model\CreateContact();

$create_contact['email'] = '[email protected]';
$create_contact['listIds'] = array(2);

try {
    $result = $api_instance->createContact($create_contact);
    print_r($result);
} catch (Exception $e) {
    print_r($e);
    echo 'Exception when calling ContactsApi->createContact: ', $e->getMessage(), PHP_EOL;
}

Where print_r($e); will give you complete ApiException Object
Thanks

from apiv3-php-library.

bjornbos avatar bjornbos commented on July 17, 2024

What about custom attributes? When I add

$create_contact['attributes'] = array('some_attribute' => 'some value')

I get the 400 error again.

from apiv3-php-library.

bjornbos avatar bjornbos commented on July 17, 2024

I've also tried to wrap it as a json object:

$create_contact['attributes'] = json_encode(array('some_attribute' => 'some value'))

The contact is then saved, but not the attributes.

from apiv3-php-library.

stefanogit avatar stefanogit commented on July 17, 2024

I'm trying to to add an attribute value but nothing... any solutions?

from apiv3-php-library.

vishalpawar-tudip avatar vishalpawar-tudip commented on July 17, 2024

Any update here, please?
I am also getting same 400 error code while creating contact.

from apiv3-php-library.

Faab avatar Faab commented on July 17, 2024

I got this error because contact already exists in another list. The error message is not clear.
Add parameter updateEnabled = true solved the problem.

https://developers.sendinblue.com/v3.0/reference#createcontact

from apiv3-php-library.

devNicolasNmk avatar devNicolasNmk commented on July 17, 2024

hello,

I have the same problem with attributes.

email is ok but attributes are not send

any idea please ?

I've also tried to wrap it as a json object:

$create_contact['attributes'] = json_encode(array('some_attribute' => 'some value'))

The contact is then saved, but not the attributes.

from apiv3-php-library.

devNicolasNmk avatar devNicolasNmk commented on July 17, 2024

@bjornbos
Thank you for your fast answer.

from apiv3-php-library.

karelbyte avatar karelbyte commented on July 17, 2024

hello, has one managed to send the attributes?, only the email is saved

from apiv3-php-library.

karelbyte avatar karelbyte commented on July 17, 2024

I, sent in the data in this way and does not save the attributes:
{"email":"[email protected]","attributes":{"FNAME":"sdgsfdgsdsf"}}

from apiv3-php-library.

korynorthrop avatar korynorthrop commented on July 17, 2024

I have been able to get some attributes to save, but am struggling to set attributes with the "Category" type (e.g. the default DOUBLE_OPT-IN attribute and a custom attribute I created called IS_SUPPORTER, both of which are "Category" attribute types with two potential values "Yes" and "No").

I was originally struggling to set the first and last name attributes for a contact because I was following the documentation, which shows those attributes as FNAME and LNAME, but I saw in the attributes table that they are actually FIRSTNAME and LASTNAME. The following code successfully sets the the first name and the GDPR_CONSENT attribute (boolean type), but doesn't update my custom category attribute (IS_SUPPORTER) or the native DOUBLE_OPT-IN category attribute.

$apiInstance = new SendinBlue\Client\Api\ContactsApi(
  new GuzzleHttp\Client(),
  $config
);

$email = '[email protected]';

$updateContact = new \SendinBlue\Client\Model\UpdateContact();

$updateContact['attributes'] = array(
	'FIRSTNAME' => 'Joe',
	'IS_SUPPORTER' => 'YES',
	'DOUBLE_OPT-IN' => 'NO',
	'GDPR_CONSENT' => true
);

try {
  $result = $apiInstance->updateContact( $email, $updateContact );
  var_dump( 'sent' );
} catch ( Exception $e ) {
  echo 'Exception when calling ContactsApi->createContact: ', $e->getMessage(), PHP_EOL;
}

from apiv3-php-library.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.