Comments (12)
I just ditched the PHP SDK and use the REST api directly. Works so much better.
from apiv3-php-library.
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.
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.
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.
I'm trying to to add an attribute value but nothing... any solutions?
from apiv3-php-library.
Any update here, please?
I am also getting same 400 error code while creating contact.
from apiv3-php-library.
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.
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.
@bjornbos
Thank you for your fast answer.
from apiv3-php-library.
hello, has one managed to send the attributes?, only the email is saved
from apiv3-php-library.
I, sent in the data in this way and does not save the attributes:
{"email":"[email protected]","attributes":{"FNAME":"sdgsfdgsdsf"}}
from apiv3-php-library.
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)
- 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.