Advertisement
Guest User

Untitled

a guest
Oct 17th, 2017
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.45 KB | None | 0 0
  1. SendinBlue\Client\Configuration::getDefaultConfiguration()->setApiKey('api-key', My_Sendinblue::API_KEY);
  2.         $api_instance = new SendinBlue\Client\Api\ContactsApi();
  3.         $created_at = new Zend_Date($this->created_at);
  4.         $updated_at = new Zend_Date($this->updated_at);
  5.         $attributes = array(
  6.                 'USERNAME' => $this->username,
  7.                 'COACH' => $this->coach,
  8.                 'SKYPE' => $this->skype,
  9.                 'FIRSTNAME' => $this->firstname,
  10.                 'LASTNAME' => $this->lastname,
  11.                 'BIRTHDAY' => $this->birthday,
  12.                 'CREATED_AT' => $created_at->toString('yyyy-MM-dd'),
  13.                 'UPDATED_AT' => $updated_at->toString('yyyy-MM-dd'),
  14.         );
  15.  
  16.         try {
  17.             $result = $api_instance->getContactInfo($this->email);
  18.             $updateContact = new \SendinBlue\Client\Model\UpdateContact();
  19.             $updateContact->setAttributes($attributes);
  20.             try {
  21.                 $api_instance->updateContact($this->email, $updateContact);
  22.             } catch (Exception $e) {
  23.                 echo 'Exception when calling ContactsApi->updateContact: ', $e->getMessage(), PHP_EOL;
  24.             }
  25.         } catch (Exception $e) {
  26.             echo 'Exception when calling ContactsApi->getContactInfo: ', $e->getMessage(), PHP_EOL;
  27.             $createContact = new \SendinBlue\Client\Model\CreateContact();
  28.             $createContact->setEmail($this->email);
  29.             $createContact->setAttributes($attributes);
  30.             try {
  31.                 $result = $api_instance->createContact($createContact);
  32.             } catch (Exception $e) {
  33.                 echo 'Exception when calling ContactsApi->createContact: ', $e->getMessage(), PHP_EOL;
  34.             }
  35.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement