arindam / sendlane-apis
用于Sendlane APIs (v2)的Laravel包
v3.0.0
2024-02-04 14:50 UTC
This package is auto-updated.
Last update: 2024-09-03 09:02:51 UTC
README
用于集成所有Sendlane APIs (v2)的Laravel包
50+ 个API供您使用。让您的开发更简单!!
安装
不依赖于PHP版本和LARAVEL版本
步骤1:运行composer命令
composer require arindam/sendlane-apis
步骤2:Laravel不带自动发现
如果您不使用自动发现,请将ServiceProvider添加到config/app.php中的providers数组中
Arindam\SendlaneApis\SendlaneApiServiceProvider::class,
您需要使用以下外观,将其添加到config/app.php中的aliases部分
'SendlaneApis' => Arindam\SendlaneApis\Sendlane\SendlaneClassFacade::class,
步骤3:(可选)发布包配置
如果您需要自定义API配置
php artisan vendor:publish --provider="Arindam\SendlaneApis\SendlaneApiServiceProvider" --force - OR - php artisan vendor:publish --tag="sendlaneapis:config"
如何使用?
首先,您需要创建Sendlane(https://www.sendlane.com/)账户并生成一个API令牌。然后,您只需在.env文件中添加以下信息即可
如下
SENDLANE_API_TOKEN=YOUR_API_TOKEN
现在享受以下方法
列出API
//Get all lists 1. SendlaneApis::allLists(); //Create a list $data = array('name' => 'your list name', 'description' => 'your list description'); 2. SendlaneApis::createList($data); //Get a list details by list id 3. SendlaneApis::listById($listId); //Update a list by list id $data = array('name' => 'your edited list name', 'description' => 'your edited list description'); 4. SendlaneApis::updateList($listId, $data); //Delete a list by list id 5. SendlaneApis::deleteList($listId);
标签API
//Get all tags 1. SendlaneApis::allTags(); //Create a tag $data = array('name' => 'your tag name'); 2. SendlaneApis::createTag($data); //Update a tag by tag id $data = array('name' => 'your edited tag name'); 3. SendlaneApis::updateTag($tagId, $data); //Delete a tag by tag id 4. SendlaneApis::deleteTag($tagId);
自定义字段API
//Get all custom fields 1. SendlaneApis::allCustomFields(); //Create a custom field $data = array('name' => 'your custom field name'); 2. SendlaneApis::createCustomField($data); //Get a custom field details by custom field id 3. SendlaneApis::customFieldById($customFieldId); //Update a custom field by custom field id $data = array('name' => 'your edited custom field name'); 4. SendlaneApis::updateCustomField($customFieldId, $data);
联系资料API
//Add a contact to a list $listId = 6; // your list id $contactDetails['first_name'] = "Arindam"; $contactDetails['last_name'] = "Roy"; $contactDetails['email'] = "arindam.roy.developer@gmail.com"; $contactDetails['phone'] = "4844731832"; //phone number should be valid $emailConsent = true or false $smsConsent = true or false $customFields = array( array('id' => [YOUR_CUSTOM_FIELD_ID], 'value' => [YOUR_CUSTOM_FIELD_VALUE]), array('id' => [YOUR_CUSTOM_FIELD_ID], 'value' => [YOUR_CUSTOM_FIELD_VALUE]). ...... ...... ); $tagIds = array('YOUR_TAG_ID1', 'YOUR_TAG_ID2', ....); // $listId and $contactDetails - parameters are required else are optional 1. SendlaneApis::addContactToList($listId, $contactDetails, $emailConsent, $smsConsent, $customFields, $tagIds); //Get all contacts 2. SendlaneApis::allContacts(); //Get a contact by the contact id 3. SendlaneApis::contactById($contactId); //Delete a contact by the contact id 4. SendlaneApis::deleteContactById($contactId); //Get a list of Un-Subscribed contacts 5. SendlaneApis::allUnsubscribedContacts(); //Get all custom fields for a specific contact using the contact id 6. SendlaneApis::allCustomFieldsForContact($contactId); //Get a custom field information for a specific contact using the contact id and the custom field id 7. SendlaneApis::customFieldInfoByContact($contactId, $contactCustomFieldId); //Add custom fields for a specific contact using the contact id and the custom fields array $contactId = 1233 // your contact id $customFields = array( array('id' => [YOUR_CUSTOM_FIELD_ID], 'value' => [YOUR_CUSTOM_FIELD_VALUE]), array('id' => [YOUR_CUSTOM_FIELD_ID], 'value' => [YOUR_CUSTOM_FIELD_VALUE]). ...... ...... ); 8. SendlaneApis::addCustomFieldsToContact($contactId, $customFields); //Delete a custom field for a specific contact using the contact id and the custom field id 9. SendlaneApis::removeCustomFieldFromContact($contactId, $contactCustomFieldId); //Get all detail information for a specific contact using the contact id 10. SendlaneApis::contactHistory($contactId); //Find a contact by email id 11. SendlaneApis::contactByEmail($email); //Find a contact by phone number 12. SendlaneApis::contactByPhone($phone); //Find a contact by email id or phone number 13. SendlaneApis::contactByPhoneEmail($phone, $email); //Get all segments for a contact using the contact id 14. SendlaneApis::contactSegments($contactId); //Get all subscription list for a contact using the contact id 15. SendlaneApis::contactSubscription($contactId); //Get all subscription list for a contact using the contact email id 16. SendlaneApis::findSubscriptionByEmail($email); //Get all subscription list for a contact using the contact phone number 17. SendlaneApis::findSubscriptionByPhone($phone); //Get all tags for a contact using the contact id 18. SendlaneApis::contactTags($contactId); //Get a tag information for a specific contact using the contact id and the tag id 19. SendlaneApis::contactTagInfo($contactId, $tagId); //Add tags for a contact by using contact id and tags array $contactId = 1233 // your contact id $tagIds = array('YOUR_TAG_ID1', 'YOUR_TAG_ID2', ....); 20. SendlaneApis::addTagToContact($contactId, $tagIds); //Delete a tag for a specific contact using the contact id and the tag id 21. SendlaneApis::removeTagFromContact($contactId, $tagId); //Un-subscribe from all list for a contact using contact id 22. SendlaneApis::unsubscribeContact($contactId); //Get all contacts in a list by list id 23. SendlaneApis::contactInList($listId); //Get contact information in details for contact in a list by list id and contact id 24. SendlaneApis::contactInfoInList($contactId, $listId); //Delete a contact for a list by list id and contact id 25. SendlaneApis::deleteContactFromList($contactId, $listId); //Get all contacts who are unsubscribed for a list by list id 26. SendlaneApis::unsubscribedContactsFromList($listId); //Delete a contact by email id 27. SendlaneApis::deleteContactByEmail($email); //Delete a contact by phone number 28. SendlaneApis::deleteContactByPhone($phone);
SMS同意API
//Check SMS consent enable or disable for a contact using contact id 1. SendlaneApis::checkSMSconsent($contactId); //Add SMS consent for a contact using contact id and valid phone number 2. SendlaneApis::addSMSconsent($contactId, $phone); //Add SMS consent for a contact using email id or phone number 3. SendlaneApis::addSMSconsentByEmailOrPhone($phone, $email); //Remove SMS consent for a contact using contact id 4. SendlaneApis::removeSMSconsent($contactId);
请查看Sendlane API文档
许可协议
MIT许可协议(MIT)。更多信息请参阅许可文件
提交问题:如果发现任何问题
如果有任何问题,请联系我。