├── LICENSE ├── README.md ├── c# ├── Asset │ ├── Channels │ │ ├── GetChannelByName.cs │ │ └── GetChannels.cs │ ├── EmailTemplates │ │ ├── ApproveEmailTemplateDraft.cs │ │ ├── CloneEmailTemplate.cs │ │ ├── CreateEmailTemplate.cs │ │ ├── DeleteEmailTemplate.cs │ │ ├── DiscardEmailTemplateDraft.cs │ │ ├── GetEmailTemplateByID.cs │ │ ├── GetEmailTemplateByName.cs │ │ ├── GetEmailTemplateContentByID.cs │ │ ├── GetEmailTemplates.cs │ │ ├── UnapproveEmailTemplateDraft.cs │ │ ├── UpdateEmailTemplateContent.cs │ │ └── UpdateEmailTemplateMetadata.cs │ ├── Emails │ │ ├── ApproveEmailDraft.cs │ │ ├── CloneEmail.cs │ │ ├── CreateEmail.cs │ │ ├── DeleteEmail.cs │ │ ├── DiscardEmailDraft.cs │ │ ├── GetEmailByID.cs │ │ ├── GetEmailByName.cs │ │ ├── GetEmailContent.cs │ │ ├── GetEmails.cs │ │ ├── SendSampleEmail.cs │ │ ├── UnapproveEmail.cs │ │ ├── UpdateEmailContent.cs │ │ ├── UpdateEmailContentSection.cs │ │ └── UpdateEmailMetadata.cs │ ├── Files │ │ ├── CreateFile.cs │ │ ├── GetFileByID.cs │ │ ├── GetFileByName.cs │ │ └── GetFiles.cs │ ├── Folders │ │ ├── CreateFolder.cs │ │ ├── DeleteFolder.cs │ │ ├── GetFolderByID.cs │ │ ├── GetFolderByName.cs │ │ ├── GetFolderContents.cs │ │ ├── GetFolders.cs │ │ └── UpdateFolderMetadata.cs │ ├── LandingPageTemplates │ │ ├── CreateLandingPageTemplate.cs │ │ ├── GetLandingPageTemplateByID.cs │ │ ├── GetLandingPageTemplateByName.cs │ │ ├── GetLandingPageTemplateContent.cs │ │ ├── GetLandingPageTemplates.cs │ │ ├── UpdateLandingPageTemplateContent.cs │ │ └── UpdateLandingPageTemplateMetadata.cs │ ├── Programs │ │ ├── ApproveProgram.cs │ │ ├── CloneProgram.cs │ │ ├── CreatePrograms.cs │ │ ├── DeleteProgram.cs │ │ ├── GetProgramByID.cs │ │ ├── GetProgramByName.cs │ │ ├── GetPrograms.cs │ │ ├── UnapproveProgram.cs │ │ └── UpdateProgramMetadata.cs │ ├── Snippets │ │ ├── ApproveSnippetDraft.cs │ │ ├── CloneSnippet.cs │ │ ├── CreateSnippet.cs │ │ ├── DeleteSnippet.cs │ │ ├── DiscardSnippetDraft.cs │ │ ├── GetDynamicContent.cs │ │ ├── GetSnippetByID.cs │ │ ├── GetSnippetContent.cs │ │ ├── GetSnippets.cs │ │ ├── UnapproveSnippet.cs │ │ ├── UpdateSnippetContent.cs │ │ ├── UpdateSnippetDynamicContent.cs │ │ └── UpdateSnippetMetadata.cs │ ├── Tags │ │ ├── GetTagByName.cs │ │ └── GetTagTypes.cs │ └── Tokens │ │ ├── ApproveEmailTemplateDraft.php │ │ ├── CloneEmailTemplate.php │ │ ├── CreateEmailTemplate.php │ │ ├── CreateToken.cs │ │ ├── DeleteEmailTemplate.php │ │ ├── DeleteTokenByName.cs │ │ ├── DeleteTokenByName.php │ │ ├── DiscardEmailTemplateDraft.php │ │ ├── GetEmailTemplateByID.php │ │ ├── GetEmailTemplateByName.php │ │ ├── GetEmailTemplateContentByID.php │ │ ├── GetEmailTemplates.php │ │ ├── GetTokensByFolderID.cs │ │ ├── GetTokensByFolderID.php │ │ ├── UnapproveEmailTemplateDraft.php │ │ ├── UpdateEmailTemplateContent.php │ │ └── UpdateEmailTemplateMetadata.php ├── Authentication │ └── Identity │ │ └── Identity.cs └── LeadDatabase │ ├── Activities │ ├── GetActivityTypes.cs │ ├── GetDeletedLeads.cs │ ├── GetLeadActivities.cs │ ├── GetLeadChanges.cs │ └── GetPagingToken.cs │ ├── Campaigns │ ├── GetCampaignByID.cs │ ├── GetCampaigns.cs │ ├── RequestCampaign.cs │ └── ScheduleCampaign.cs │ ├── Companies │ ├── DeleteCompanies.cs │ ├── DescribeCompanies.cs │ ├── GetCompanies.cs │ └── SyncCompanies.cs │ ├── CustomObjects │ ├── DeleteCustomObjects.cs │ ├── DescribeCustomObjects.cs │ ├── DescribeOpportunity.cs │ ├── GetCustomObjects.cs │ ├── ListOfCustomObjects.cs │ └── SyncCustomObjects.cs │ ├── Leads │ ├── AssociateLead.cs │ ├── AssociateLeads.cs │ ├── DeleteLeads.cs │ ├── DescribeLead.cs │ ├── GetLeadById.cs │ ├── GetLeadPartitions.cs │ ├── GetLeadsByFilterType.cs │ ├── GetLeadsByProgramID.cs │ ├── MergeLeads.cs │ └── SyncLeads.cs │ ├── Opportunities │ ├── DeleteOpportunities.cs │ ├── DeleteOpportunityRoles.cs │ ├── DescribeOpportunity.cs │ ├── DescribeOpportunityRole.cs │ ├── GetOpportunities.cs │ ├── GetOpportunityRoles.cs │ ├── SyncOpportunities.cs │ └── SyncOpportunityRoles.cs │ ├── SalesPersons │ ├── DeleteSalesPersons.cs │ ├── DescribeSalesPersons.cs │ ├── GetSalesPersons.cs │ └── SyncSalesPersons.cs │ ├── StaticLists │ ├── AddToList.cs │ ├── GetLeadsByListID.cs │ ├── GetListById.cs │ ├── GetLists.cs │ ├── MemberOfList.cs │ └── RemoveFromList.cs │ └── Usage │ ├── GetDailyErrors.cs │ ├── GetDailyUsage.cs │ ├── GetWeeklyErrors.cs │ └── GetWeeklyUsage.cs ├── java ├── Asset │ ├── Channels │ │ ├── GetChannelByName.java │ │ └── GetChannels.java │ ├── EmailTemplates │ │ ├── ApproveEmailTemplateDraft.java │ │ ├── CloneEmailTemplate.java │ │ ├── CreateEmailTemplate.java │ │ ├── DeleteEmailTemplate.java │ │ ├── DiscardEmailTemplateDraft.java │ │ ├── GetEmailTemplateByID.java │ │ ├── GetEmailTemplateByName.java │ │ ├── GetEmailTemplateContentByID.java │ │ ├── GetEmailTemplates.java │ │ ├── UnapproveEmailTemplateDraft.java │ │ ├── UpdateEmailTemplateContent.java │ │ └── UpdateEmailTemplateMetadata.java │ ├── Emails │ │ ├── ApproveEmailDraft.java │ │ ├── CloneEmail.java │ │ ├── CreateEmail.java │ │ ├── DeleteEmail.java │ │ ├── DiscardEmailDraft.java │ │ ├── GetEmailByID.java │ │ ├── GetEmailByName.java │ │ ├── GetEmailContent.java │ │ ├── GetEmails.java │ │ ├── SendSampleEmail.java │ │ ├── UnapproveEmail.java │ │ ├── UpdateEmailContent.java │ │ ├── UpdateEmailContentSection.java │ │ └── UpdateEmailMetadata.java │ ├── Files │ │ ├── CreateFile.java │ │ ├── GetFileByID.java │ │ ├── GetFileByName.java │ │ └── GetFiles.java │ ├── Folders │ │ ├── CreateFolder.java │ │ ├── DeleteFolder.java │ │ ├── GetFolderByID.java │ │ ├── GetFolderByName.java │ │ ├── GetFolders.java │ │ └── UpdateFolderMetadata.java │ ├── LandingPageTemplates │ │ ├── CreateLandingPageTemplate.java │ │ ├── GetLandingPageTemplateByID.java │ │ ├── GetLandingPageTemplateByName.java │ │ ├── GetLandingPageTemplateContent.java │ │ ├── GetLandingPageTemplates.java │ │ ├── UpdateLandingPageTemplateContent.java │ │ └── UpdateLandingPageTemplateMetadata.java │ ├── Programs │ │ ├── ApproveProgram.java │ │ ├── CloneProgram.java │ │ ├── CreatePrograms.java │ │ ├── DeleteProgram.java │ │ ├── GetProgramByID.java │ │ ├── GetProgramByName.java │ │ ├── GetPrograms.java │ │ ├── UnapproveProgram.java │ │ └── UpdateProgramMetadata.java │ ├── Segments │ │ ├── GetSegmentations.java │ │ └── GetSegmentsForSegmentation.java │ ├── Snippets │ │ ├── ApproveSnippetDraft.java │ │ ├── CloneSnippet.java │ │ ├── CreateSnippet.java │ │ ├── DeleteSnippet.java │ │ ├── DiscardSnippetDraft.java │ │ ├── GetDynamicContent.java │ │ ├── GetSnippetByID.java │ │ ├── GetSnippetContent.java │ │ ├── GetSnippets.java │ │ ├── UnapproveSnippet.java │ │ ├── UpdateSnippetContent.java │ │ ├── UpdateSnippetDynamicContent.java │ │ └── UpdateSnippetMetadata.java │ ├── Tags │ │ ├── GetTagByName.java │ │ └── GetTagTypes.java │ └── Tokens │ │ ├── CreateToken.java │ │ ├── DeleteTokenByName.java │ │ └── GetTokensByFolderID.java ├── Authentication │ └── Identity │ │ └── Identity.java └── LeadDatabase │ ├── Activities │ ├── AddCustomActivities.java │ ├── GetActivityTypes.java │ ├── GetDeletedLeads.java │ ├── GetLeadActivities.java │ ├── GetLeadChanges.java │ └── GetPagingToken.java │ ├── BulkLeads │ ├── GetImportLeadFailures.java │ ├── GetImportLeadStatus.java │ ├── GetImportLeadWarnings.java │ └── ImportLeads.java │ ├── Campaigns │ ├── GetCampaignByID.java │ ├── GetCampaigns.java │ ├── RequestCampaign.java │ └── ScheduleCampaign.java │ ├── Companies │ ├── DeleteCompanies.java │ ├── DescribeCompanies.java │ ├── GetCompanies.java │ └── SyncCompanies.java │ ├── CustomObjects │ ├── DeleteCustomObjects.java │ ├── DescribeCustomObjects.java │ ├── GetCustomObjects.java │ ├── ListOfCustomObjects.java │ └── SyncCustomObjects.java │ ├── Leads │ ├── AssociateLead.java │ ├── DeleteLeads.java │ ├── DescribeLead.java │ ├── GetLeadByID.java │ ├── GetLeadPartitions.java │ ├── GetLeadsByFilterType.java │ ├── GetLeadsByProgramID.java │ ├── MergeLeads.java │ └── SyncLeads.java │ ├── Opportunities │ ├── DeleteOpportunities.java │ ├── DeleteOpportunityRoles.java │ ├── DescribeOpportunity.java │ ├── DescribeOpportunityRole.java │ ├── GetOpportunities.java │ ├── GetOpportunityRoles.java │ ├── SyncOpportunities.java │ └── SyncOpportunityRoles.java │ ├── SalesPersons │ ├── DeleteSalesPersons.java │ ├── DescribeSalesPersons.java │ ├── GetSalesPersons.java │ └── SyncSalesPersons.java │ ├── StaticLists │ ├── AddToList.java │ ├── GetLeadsByListID.java │ ├── GetListByID.java │ ├── GetLists.java │ ├── MemberOfList.java │ └── RemoveFromList.java │ └── Usage │ ├── GetDailyErrors.java │ ├── GetDailyUsage.java │ ├── GetWeeklyErrors.java │ └── GetWeeklyUsage.java ├── php ├── Asset │ ├── Channels │ │ ├── GetChannelByName.php │ │ └── GetChannels.php │ ├── EmailTemplates │ │ ├── ApproveEmailTemplateDraft.php │ │ ├── CloneEmailTemplate.php │ │ ├── CreateEmailTemplate.php │ │ ├── DeleteEmailTemplate.php │ │ ├── DiscardEmailTemplateDraft.php │ │ ├── GetEmailTemplateByID.php │ │ ├── GetEmailTemplateByName.php │ │ ├── GetEmailTemplateContentByID.php │ │ ├── GetEmailTemplates.php │ │ ├── UnapproveEmailTemplateDraft.php │ │ ├── UpdateEmailTemplateContent.php │ │ └── UpdateEmailTemplateMetadata.php │ ├── Emails │ │ ├── ApproveEmailDraft.php │ │ ├── CloneEmail.php │ │ ├── CreateEmail.php │ │ ├── DeleteEmail.php │ │ ├── DiscardEmailDraft.php │ │ ├── GetEmailByID.php │ │ ├── GetEmailByName.php │ │ ├── GetEmailContent.php │ │ ├── SendSampleEmail.php │ │ ├── UnapproveEmail.php │ │ ├── UpdateEmailContent.php │ │ ├── UpdateEmailContentSection.php │ │ ├── UpdateEmailDynamicContent.php │ │ ├── UpdateEmailDynamicContentSection.php │ │ └── UpdateEmailMetadata.php │ ├── Files │ │ ├── CreateFile.php │ │ ├── GetFileByID.php │ │ ├── GetFileByName.php │ │ └── GetFiles.php │ ├── Folders │ │ ├── CreateFolder.php │ │ ├── DeleteFolder.php │ │ ├── GetFolderByID.php │ │ ├── GetFolderByName.php │ │ ├── GetFolderContents.php │ │ ├── GetFolders.php │ │ └── UpdateFolderMetadata.php │ ├── LandingPageTemplates │ │ ├── CreateLandingPageTemplate.php │ │ ├── GetLandingPageTemplateByID.php │ │ ├── GetLandingPageTemplateByName.php │ │ ├── GetLandingPageTemplateContent.php │ │ ├── GetLandingPageTemplates.php │ │ ├── UpdateLandingPageTemplateContent.php │ │ └── UpdateLandingPageTemplateMetadata.php │ ├── Programs │ │ ├── ApproveProgram.php │ │ ├── CloneProgram.php │ │ ├── CreatePrograms.php │ │ ├── DeleteProgram.php │ │ ├── GetProgramByID.php │ │ ├── GetProgramByName.php │ │ ├── GetPrograms.php │ │ ├── GetProgramsByTag.php │ │ ├── UnapproveProgram.php │ │ └── UpdateProgramMetadata.php │ ├── Segments │ │ ├── GetSegmentations.php │ │ └── GetSegmentsForSegmentations.php │ ├── Snippets │ │ ├── ApproveSnippetDraft.php │ │ ├── CloneSnippet.php │ │ ├── CreateSnippet.php │ │ ├── DeleteSnippet.php │ │ ├── DiscardSnippetDraft.php │ │ ├── GetDynamicContent.php │ │ ├── GetSnippetByID.php │ │ ├── GetSnippetContent.php │ │ ├── GetSnippets.php │ │ ├── UnapproveSnippet.php │ │ ├── UpdateSnippetContent.php │ │ ├── UpdateSnippetDynamicContent.php │ │ └── UpdateSnippetMetadata.php │ ├── Tags │ │ ├── GetTagByName.php │ │ └── GetTagTypes.php │ └── Tokens │ │ ├── CreateToken.php │ │ ├── DeleteTokenByName.php │ │ └── GetTokensByFolderID.php └── LeadDatabase │ ├── Activities │ ├── GetActivityTypes.php │ ├── GetLeadActivities.php │ ├── GetLeadChanges.php │ └── GetPagingToken.php │ ├── BulkLeads │ ├── GetImportLeadFailures.php │ ├── GetImportLeadStatus.php │ ├── GetImportLeadWarnings.php │ └── ImportLeads.php │ ├── Campaigns │ ├── GetCampaignByID.php │ ├── GetCampaigns.php │ ├── RequestCampaign.php │ └── ScheduleCampaign.php │ ├── Companies │ ├── DeleteCompanies.php │ ├── DescribeCompanies.php │ ├── GetCompanies.php │ └── SyncCompanies.php │ ├── CustomObjects │ ├── DeleteCustomObjects.php │ ├── DescribeCustomObjects.php │ ├── GetCustomObjects.php │ ├── ListOfCustomObjects.php │ └── SyncCustomObjects.php │ ├── Leads │ ├── AssociateLead.php │ ├── DeleteLeads.php │ ├── GetLeadByID.php │ ├── GetLeadPartitions.php │ ├── GetLeadsByFilterType.php │ ├── GetLeadsByProgramID.php │ ├── MergeLeads.php │ ├── PushLeadToMarketo.php │ └── SyncLeads.php │ ├── Opportunities │ ├── DeleteOpportunities.php │ ├── DeleteOpportunityRoles.php │ ├── DescribeOpportunity.php │ ├── DescribeOpportunityRole.php │ ├── GetOpportunities.php │ ├── GetOpportunityRoles.php │ ├── SyncOpportunities.php │ └── SyncOpportunityRoles.php │ ├── SalesPersons │ ├── DeleteSalesPersons.php │ ├── DescribeSalesPersons.php │ ├── GetSalesPersons.php │ └── SyncSalesPersons.php │ ├── StaticLists │ ├── AddToList.php │ ├── GetLeadsByListID.php │ ├── GetListByID.php │ ├── GetLists.php │ ├── MemberOfList.php │ └── RemoveFromList.php │ └── Usage │ ├── GetDailyErrors.php │ ├── GetDailyUsage.php │ ├── GetWeeklyErrors.php │ └── GetWeeklyUsage.php ├── python └── LeadDatabase │ └── Leads │ ├── README.md │ └── get_every_lead.py └── ruby ├── Asset ├── EmailTemplates │ ├── ApproveEmailTemplateDraft.rb │ ├── CloneEmailTemplate.rb │ ├── CreateEmailTemplate.rb │ ├── DeleteEmailTemplate.rb │ ├── DiscartEmailTemplateDraft.rb │ ├── GetEmailTemplateByID.rb │ ├── GetEmailTemplateByName.rb │ ├── GetEmailTemplateContentByID.rb │ ├── GetEmailTemplates.rb │ ├── UnapproveEmailTemplateDraft.rb │ ├── UpdateEmailTemplateContent.rb │ └── UpdateEmailTemplateMetadata.rb ├── Emails │ ├── ApproveEmailDraft.rb │ ├── CloneEmail.rb │ ├── CreateEmail.rb │ ├── DeleteEmail.rb │ ├── DiscardEmailDraft.rb │ ├── GetEmailByID.rb │ ├── GetEmailByName.rb │ ├── GetEmailContent.rb │ ├── GetEmailDynamicContent.rb │ ├── GetEmails.rb │ ├── GetFileByID.rb │ ├── GetFileByName.rb │ ├── GetFiles.rb │ ├── SendSampleEmail.rb │ ├── UnapproveEmail.rb │ ├── UpdateEmailContent.rb │ ├── UpdateEmailContentSection.rb │ ├── UpdateEmailDynamicContentSection.rb │ └── UpdateEmailMetadata.rb ├── Files │ ├── CreateFile.rb │ ├── GetFileByID.rb │ ├── GetFileByName.rb │ └── GetFiles.rb ├── LandingPageTemplates │ ├── CreateLandingPageTemplate.rb │ ├── GetLandingPageTemplateByID.rb │ ├── GetLandingPageTemplateByName.rb │ ├── GetLandingPageTemplateContent.rb │ ├── GetLandingPageTemplates.rb │ ├── UpdateLandingPageTemplateContent.rb │ └── UpdateLandingPageTemplateContentMetadata.rb ├── Snippets │ ├── ApproveSnippetDraft.rb │ ├── CloneSnippet.rb │ ├── CreateSnippet.rb │ ├── DeleteSnippet.rb │ ├── DiscardSnippetDraft.rb │ ├── GetDynamicContent.rb │ ├── GetSnippetByID.rb │ ├── GetSnippetContent.rb │ ├── GetSnippets.rb │ ├── UnapproveSnippet.rb │ ├── UpdateSnippetContent.rb │ ├── UpdateSnippetDynamicContent.rb │ └── UpdateSnippetMetadata.rb └── Tokens │ ├── CreateToken.rb │ ├── DeleteTokensByName.rb │ └── GetTokensByFolderID.rb ├── Authentication └── Identity │ └── Identity.rb └── LeadDatabase ├── Activities ├── GetActivityTypes.rb ├── GetLeadActivities.rb ├── GetLeadChanges.rb └── GetPagingToken.rb ├── BulkLeads ├── GetImportLeadFailures.rb ├── GetImportLeadStatus.rb └── GetImportLeadWarnings.rb ├── Campaigns ├── GetCampaignByID.rb ├── GetCampaigns.rb ├── RequestCampaign.rb └── ScheduleCampaign.rb ├── Companies ├── DeleteCompanies.rb ├── DescribeCompanies.rb ├── GetCompanies.rb └── SyncCompanies.rb ├── CustomObjects ├── DeleteCustomObjects.rb ├── DescribeCustomObjects.rb ├── GetCustomObjects.rb ├── ListOfCustomObjects.rb └── SyncCustomObjects.rb ├── Leads ├── AssociateLead.rb ├── DescribeLead.rb ├── GetLeadById.rb ├── GetLeadPartitions.rb ├── GetLeadsByFilterType.rb ├── MergeLeads.rb └── SyncLeads.rb ├── Opportunities ├── DeleteOpportunities.rb ├── DeleteOpportunityRoles.rb ├── DescribeOpportuniityRole.rb ├── DescribeOpportunity.rb ├── GetOpportunities.rb ├── GetOpportunityRoles.rb ├── SyncOpportunities.rb └── SyncOpportunityRoles.rb ├── SalesPersons ├── DeleteSalesPersons.rb ├── DescribeSalesPersons.rb ├── GetSalesPersons.rb └── SyncSalesPersons.rb ├── StaticLists ├── AddToList.rb ├── GetLeadsByListID.rb ├── GetListByID.rb ├── GetLists.rb ├── MemberOfList.rb └── RemoveFromList.rb └── Usage ├── GetDailyErrors.rb ├── GetDailyUsage.rb ├── GetWeeklyErrors.rb └── GetWeeklyUsage.rb /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Marketo, Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /c#/Asset/Tokens/ApproveEmailTemplateDraft.php: -------------------------------------------------------------------------------- 1 | id = 1; 4 | print_r($sample->postData()); 5 | 6 | class ApproveEmailTemplate{ 7 | private $host = "CHANGE ME"; 8 | private $clientId = "CHANGE ME"; 9 | private $clientSecret = "CHANGE ME"; 10 | public $id; //id of template to delete 11 | 12 | public function postData(){ 13 | $url = $this->host . "/rest/asset/v1/emailTemplate/" . $this->id . "/approveDraft.json?access_token=" . $this->getToken(); 14 | $ch = curl_init($url); 15 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 16 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json')); 17 | curl_setopt($ch, CURLOPT_POST, 1); 18 | curl_getinfo($ch); 19 | $response = curl_exec($ch); 20 | return $response; 21 | } 22 | 23 | private function getToken(){ 24 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 25 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 26 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 27 | $response = json_decode(curl_exec($ch)); 28 | curl_close($ch); 29 | $token = $response->access_token; 30 | return $token; 31 | } 32 | } -------------------------------------------------------------------------------- /c#/Asset/Tokens/DeleteEmailTemplate.php: -------------------------------------------------------------------------------- 1 | id = 1; 4 | print_r($delete->postData()); 5 | 6 | class DeleteEmailTemplate{ 7 | private $host = "CHANGE ME"; 8 | private $clientId = "CHANGE ME"; 9 | private $clientSecret = "CHANGE ME"; 10 | public $id; //id of template to delete 11 | 12 | public function postData(){ 13 | $url = $this->host . "/rest/asset/v1/emailTemplate/" . $this->id . "/delete.json?access_token=" . $this->getToken(); 14 | $ch = curl_init($url); 15 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 16 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json')); 17 | curl_setopt($ch, CURLOPT_POST, 1); 18 | curl_getinfo($ch); 19 | $response = curl_exec($ch); 20 | return $response; 21 | } 22 | 23 | private function getToken(){ 24 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 25 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 26 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 27 | $response = json_decode(curl_exec($ch)); 28 | curl_close($ch); 29 | $token = $response->access_token; 30 | return $token; 31 | } 32 | } -------------------------------------------------------------------------------- /c#/Asset/Tokens/DeleteTokenByName.php: -------------------------------------------------------------------------------- 1 | id = 1071; 4 | $delete->folderType = "Program"; 5 | $delete->name = "New Token - PHP"; 6 | $delete->type = "text"; 7 | print_r($delete->postData()); 8 | 9 | 10 | class DeleteTokens{ 11 | private $host = "CHANGE ME"; 12 | private $clientId = "CHANGE ME"; 13 | private $clientSecret = "CHANGE ME"; 14 | //all params required 15 | public $id;//id of folder to delete from 16 | public $folderType;//type of folder to delete from 17 | public $name;//name of token to delete 18 | public $type;//type of token to delete 19 | 20 | public function postData(){ 21 | $url = $this->host . "/rest/asset/v1/folder/" . $this->id . "/tokens/delete.json?access_token=" . $this->getToken() 22 | . "&folderType=" . $this->folderType . "&name=" . $this->name . "&type=" . $this->type; 23 | $ch = curl_init($url); 24 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 25 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json')); 26 | curl_setopt($ch, CURLOPT_POST, 1); 27 | $response = curl_exec($ch); 28 | return $response; 29 | } 30 | 31 | private function getToken(){ 32 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 33 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 34 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 35 | $response = json_decode(curl_exec($ch)); 36 | curl_close($ch); 37 | $token = $response->access_token; 38 | return $token; 39 | } 40 | private function bodyBuilder(){ 41 | 42 | } 43 | } -------------------------------------------------------------------------------- /c#/Asset/Tokens/DiscardEmailTemplateDraft.php: -------------------------------------------------------------------------------- 1 | id = 1; 4 | print_r($clone->postData()); 5 | 6 | class DiscardEmailTemplateDraft{ 7 | private $host = "CHANGE ME"; 8 | private $clientId = "CHANGE ME"; 9 | private $clientSecret = "CHANGE ME"; 10 | public $id; //id of template to delete 11 | 12 | public function postData(){ 13 | $url = $this->host . "/rest/asset/v1/emailTemplate/" . $this->id . "/discardDraft.json?access_token=" . $this->getToken(); 14 | $ch = curl_init($url); 15 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 16 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json')); 17 | curl_setopt($ch, CURLOPT_POST, 1); 18 | curl_getinfo($ch); 19 | $response = curl_exec($ch); 20 | return $response; 21 | } 22 | 23 | private function getToken(){ 24 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 25 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 26 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 27 | $response = json_decode(curl_exec($ch)); 28 | curl_close($ch); 29 | $token = $response->access_token; 30 | return $token; 31 | } 32 | } -------------------------------------------------------------------------------- /c#/Asset/Tokens/GetEmailTemplateByID.php: -------------------------------------------------------------------------------- 1 | id = 1001; 4 | print_r($emailTemplate->getData()); 5 | 6 | 7 | class GetEmailTemplate{ 8 | private $host = "CHANGE ME"; 9 | private $clientId = "CHANGE ME"; 10 | private $clientSecret = "CHANGE ME"; 11 | public $id; //id of the template to retrieve, required 12 | public $status; //optional status filter 13 | 14 | public function getData(){ 15 | $url = $this->host . "/rest/asset/v1/emailTemplate/" . $this->id . ".json?access_token=" . $this->getToken(); 16 | if (isset($this->status)){ 17 | $url .= "&status=" . $this->status; 18 | } 19 | $ch = curl_init($url); 20 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 21 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 22 | $response = curl_exec($ch); 23 | return $response; 24 | } 25 | 26 | private function getToken(){ 27 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 28 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 29 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json')); 30 | $response = json_decode(curl_exec($ch)); 31 | curl_close($ch); 32 | $token = $response->access_token; 33 | return $token; 34 | } 35 | } -------------------------------------------------------------------------------- /c#/Asset/Tokens/GetEmailTemplateByName.php: -------------------------------------------------------------------------------- 1 | name = "Sample Template - PHP"; 4 | print_r($emailTemplate->getData()); 5 | 6 | 7 | class EmailTemplateByName{ 8 | private $host = "CHANGE ME"; 9 | private $clientId = "CHANGE ME"; 10 | private $clientSecret = "CHANGE ME"; 11 | public $name;//name of template to retrieve 12 | public $status; //optional status filter 13 | 14 | public function getData(){ 15 | $url = $this->host . "/rest/asset/v1/emailTemplate/byName.json?access_token=" . $this->getToken() . "&name=" . $this->name; 16 | if (isset($this->status)){ 17 | $url .= "&status=" . $this->status; 18 | } 19 | $ch = curl_init($url); 20 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 21 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 22 | $response = curl_exec($ch); 23 | return $response; 24 | } 25 | 26 | private function getToken(){ 27 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 28 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 29 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json')); 30 | $response = json_decode(curl_exec($ch)); 31 | curl_close($ch); 32 | $token = $response->access_token; 33 | return $token; 34 | } 35 | } -------------------------------------------------------------------------------- /c#/Asset/Tokens/GetEmailTemplateContentByID.php: -------------------------------------------------------------------------------- 1 | id = 1037; 4 | print_r($content->getData()); 5 | 6 | class GetEmailTemplateContent{ 7 | private $host = "CHANGE ME"; 8 | private $clientId = "CHANGE ME"; 9 | private $clientSecret = "CHANGE ME"; 10 | public $id;//id of template to retrieve content from 11 | public $status;//optional status filter 12 | 13 | public function getData(){ 14 | $url = $this->host . "/rest/asset/v1/emailTemplate/" . $this->id . "/content?access_token=" . $this->getToken(); 15 | if (isset($this->status)){ 16 | $url .= "&status=" . $this->status; 17 | } 18 | $ch = curl_init($url); 19 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 20 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 21 | $response = curl_exec($ch); 22 | return $response; 23 | } 24 | 25 | private function getToken(){ 26 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 27 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 28 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json')); 29 | $response = json_decode(curl_exec($ch)); 30 | curl_close($ch); 31 | $token = $response->access_token; 32 | return $token; 33 | } 34 | } -------------------------------------------------------------------------------- /c#/Asset/Tokens/GetEmailTemplates.php: -------------------------------------------------------------------------------- 1 | getData()); 4 | 5 | 6 | class MultipleEmailTemplates{ 7 | private $host = "CHANGE ME"; 8 | private $clientId = "CHANGE ME"; 9 | private $clientSecret = "CHANGE ME"; 10 | public $offset;//integer offset for paging 11 | public $maxreturn;//max number of templates to return 12 | public $status;//optional status filter 13 | 14 | public function getData(){ 15 | $url = $this->host . "/rest/asset/v1/emailTemplates.json?access_token=" . $this->getToken(); 16 | if (isset($this->offset)){ 17 | $url .= "&offset=" . $this->offset; 18 | } 19 | if (isset($this->maxreturn)){ 20 | $url .= "&maxreturn=" . $this->maxreturn; 21 | } 22 | if (isset($this->status)){ 23 | $url .= "&status=" . $this->status; 24 | } 25 | $ch = curl_init($url); 26 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 27 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 28 | $response = curl_exec($ch); 29 | return $response; 30 | } 31 | 32 | private function getToken(){ 33 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 34 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 35 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json')); 36 | $response = json_decode(curl_exec($ch)); 37 | curl_close($ch); 38 | $token = $response->access_token; 39 | return $token; 40 | } 41 | } -------------------------------------------------------------------------------- /c#/Asset/Tokens/GetTokensByFolderID.php: -------------------------------------------------------------------------------- 1 | id = 1071; 4 | $tokens->folderType = "Program"; 5 | print_r($tokens->getData()); 6 | 7 | class GetTokens{ 8 | private $host = "CHANGE ME"; 9 | private $clientId = "CHANGE ME"; 10 | private $clientSecret = "CHANGE ME"; 11 | public $id;//id of folder to retrieve from 12 | public $folderType;//type of folder, Folder or Program 13 | 14 | public function getData(){ 15 | $url = $this->host . "/rest/asset/v1/folder/" . $this->id . "/tokens.json?access_token=" . $this->getToken() . "&folderType=" . $this->folderType; 16 | $ch = curl_init($url); 17 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 18 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json')); 19 | $response = curl_exec($ch); 20 | return $response; 21 | } 22 | 23 | private function getToken(){ 24 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 25 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 26 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 27 | $response = json_decode(curl_exec($ch)); 28 | curl_close($ch); 29 | $token = $response->access_token; 30 | return $token; 31 | } 32 | private static function csvString($fields){ 33 | $csvString = ""; 34 | $i = 0; 35 | foreach($fields as $field){ 36 | if ($i > 0){ 37 | $csvString = $csvString . "," . $field; 38 | }elseif ($i === 0){ 39 | $csvString = $field; 40 | } 41 | } 42 | return $csvString; 43 | } 44 | } -------------------------------------------------------------------------------- /c#/Asset/Tokens/UnapproveEmailTemplateDraft.php: -------------------------------------------------------------------------------- 1 | id = 1; 4 | print_r($clone->postData()); 5 | 6 | class UnapproveEmailTemplate{ 7 | private $host = "CHANGE ME"; 8 | private $clientId = "CHANGE ME"; 9 | private $clientSecret = "CHANGE ME"; 10 | public $id; //id of template to delete 11 | 12 | public function postData(){ 13 | $url = $this->host . "/rest/asset/v1/emailTemplate/" . $this->id . "/unapprove.json?access_token=" . $this->getToken(); 14 | $ch = curl_init($url); 15 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 16 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json')); 17 | curl_setopt($ch, CURLOPT_POST, 1); 18 | curl_getinfo($ch); 19 | $response = curl_exec($ch); 20 | return $response; 21 | } 22 | 23 | private function getToken(){ 24 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 25 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 26 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 27 | $response = json_decode(curl_exec($ch)); 28 | curl_close($ch); 29 | $token = $response->access_token; 30 | return $token; 31 | } 32 | } -------------------------------------------------------------------------------- /c#/Asset/Tokens/UpdateEmailTemplateContent.php: -------------------------------------------------------------------------------- 1 | id = 1037; 4 | $emailTemplate->content = new CURLFile("NewTemplate.HTML", "text/html", "content"); 5 | print_r($emailTemplate->postData()); 6 | 7 | class UpdateEmailTemplateContent{ 8 | private $host = "CHANGE ME"; 9 | private $clientId = "CHANGE ME"; 10 | private $clientSecret = "CHANGE ME"; 11 | public $id;//id of the teplate to update 12 | public $content; //HTML content of Template, required 13 | 14 | public function postData(){ 15 | $url = $this->host . "/rest/asset/v1/emailTemplate/" . $this->id . "/content.json?access_token=" . $this->getToken(); 16 | $ch = curl_init($url); 17 | $requestBody = array("content" => $this->content); 18 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 19 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json','Content-Type: multipart/form-data')); 20 | curl_setopt($ch, CURLOPT_POST, 1); 21 | curl_setopt($ch, CURLOPT_POSTFIELDS, $requestBody); 22 | curl_getinfo($ch); 23 | $response = curl_exec($ch); 24 | return $response; 25 | } 26 | 27 | private function getToken(){ 28 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 29 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 30 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 31 | $response = json_decode(curl_exec($ch)); 32 | curl_close($ch); 33 | $token = $response->access_token; 34 | return $token; 35 | } 36 | } -------------------------------------------------------------------------------- /c#/Authentication/Identity/Identity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net; 3 | using System.IO; 4 | using Newtonsoft.Json; // Json.NET (http://www.newtonsoft.com/json) 5 | 6 | namespace Marketo 7 | { 8 | public class Identity 9 | { 10 | public static void Main(string[] args) 11 | { 12 | String host = "CHANGE ME"; 13 | String clientId = "CHANGE ME"; 14 | String clientSecret = "CHANGE ME"; 15 | 16 | String url = string.Format("https://{0}/identity/oauth/token?grant_type=client_credentials&client_id={1}&client_secret={2}", host, clientId, clientSecret); 17 | String accessToken = Identity.getAccessToken(url); 18 | String message = String.Format("Access Token: {0}", accessToken); 19 | Console.WriteLine(message); 20 | } 21 | 22 | public static String getAccessToken(String url) 23 | { 24 | HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); 25 | request.ContentType = "application/json"; 26 | HttpWebResponse response = (HttpWebResponse)request.GetResponse(); 27 | Stream resStream = response.GetResponseStream(); 28 | StreamReader reader = new StreamReader(resStream); 29 | String json = reader.ReadToEnd(); 30 | dynamic parsedJson = JsonConvert.DeserializeObject(json); 31 | return parsedJson.access_token; 32 | } 33 | } 34 | } 35 | 36 | 37 | -------------------------------------------------------------------------------- /php/Asset/Channels/GetChannelByName.php: -------------------------------------------------------------------------------- 1 | name = "Presenter"; 14 | print_r($tag->getData()); 15 | 16 | class GetTagByName{ 17 | private $host = "CHANGE ME"; 18 | private $clientId = "CHANGE ME"; 19 | private $clientSecret = "CHANGE ME"; 20 | 21 | public $name;//name of tag to retrieve 22 | 23 | public function getData(){ 24 | $url = $this->host . "/rest/asset/v1/channel/byName.json?name=$this->name"; 25 | $ch = curl_init($url); 26 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 27 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json', "Authorization: Bearer " . $this->getToken())); 28 | $response = curl_exec($ch); 29 | return $response; 30 | } 31 | 32 | private function getToken(){ 33 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 34 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 35 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 36 | $response = json_decode(curl_exec($ch)); 37 | curl_close($ch); 38 | $token = $response->access_token; 39 | return $token; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /php/Asset/Channels/GetChannels.php: -------------------------------------------------------------------------------- 1 | getData()); 14 | 15 | class GetTags{ 16 | private $host = "CHANGE ME"; 17 | private $clientId = "CHANGE ME"; 18 | private $clientSecret = "CHANGE ME"; 19 | 20 | public $offset;//integer offset for paging 21 | public $maxReturn;//max number of records to return 22 | 23 | public function getData(){ 24 | $url = $this->host . "/rest/asset/v1/channels.json?"; 25 | if(isset($this->offset)){ 26 | $url .= "offset=$this->offset&"; 27 | } 28 | if(isset($this->maxReturn)){ 29 | $url .= "maxReturn=$this->maxReturn"; 30 | } 31 | $ch = curl_init($url); 32 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 33 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json', "Authorization: Bearer " . $this->getToken())); 34 | $response = curl_exec($ch); 35 | return $response; 36 | } 37 | 38 | private function getToken(){ 39 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 40 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 41 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 42 | $response = json_decode(curl_exec($ch)); 43 | curl_close($ch); 44 | $token = $response->access_token; 45 | return $token; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /php/Asset/EmailTemplates/ApproveEmailTemplateDraft.php: -------------------------------------------------------------------------------- 1 | id = 1; 13 | print_r($sample->postData()); 14 | 15 | class ApproveEmailTemplate{ 16 | private $host = "CHANGE ME"; 17 | private $clientId = "CHANGE ME"; 18 | private $clientSecret = "CHANGE ME"; 19 | public $id; //id of template to delete 20 | 21 | public function postData(){ 22 | $url = $this->host . "/rest/asset/v1/emailTemplate/" . $this->id . "/approveDraft.json?access_token=" . $this->getToken(); 23 | $ch = curl_init($url); 24 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 25 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json')); 26 | curl_setopt($ch, CURLOPT_POST, 1); 27 | curl_getinfo($ch); 28 | $response = curl_exec($ch); 29 | return $response; 30 | } 31 | 32 | private function getToken(){ 33 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 34 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 35 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 36 | $response = json_decode(curl_exec($ch)); 37 | curl_close($ch); 38 | $token = $response->access_token; 39 | return $token; 40 | } 41 | } -------------------------------------------------------------------------------- /php/Asset/EmailTemplates/DeleteEmailTemplate.php: -------------------------------------------------------------------------------- 1 | id = 1; 13 | print_r($delete->postData()); 14 | 15 | class DeleteEmailTemplate{ 16 | private $host = "CHANGE ME"; 17 | private $clientId = "CHANGE ME"; 18 | private $clientSecret = "CHANGE ME"; 19 | public $id; //id of template to delete 20 | 21 | public function postData(){ 22 | $url = $this->host . "/rest/asset/v1/emailTemplate/" . $this->id . "/delete.json?access_token=" . $this->getToken(); 23 | $ch = curl_init($url); 24 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 25 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json')); 26 | curl_setopt($ch, CURLOPT_POST, 1); 27 | curl_getinfo($ch); 28 | $response = curl_exec($ch); 29 | return $response; 30 | } 31 | 32 | private function getToken(){ 33 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 34 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 35 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 36 | $response = json_decode(curl_exec($ch)); 37 | curl_close($ch); 38 | $token = $response->access_token; 39 | return $token; 40 | } 41 | } -------------------------------------------------------------------------------- /php/Asset/EmailTemplates/DiscardEmailTemplateDraft.php: -------------------------------------------------------------------------------- 1 | id = 1; 13 | print_r($clone->postData()); 14 | 15 | class DiscardEmailTemplateDraft{ 16 | private $host = "CHANGE ME"; 17 | private $clientId = "CHANGE ME"; 18 | private $clientSecret = "CHANGE ME"; 19 | public $id; //id of template to delete 20 | 21 | public function postData(){ 22 | $url = $this->host . "/rest/asset/v1/emailTemplate/" . $this->id . "/discardDraft.json?access_token=" . $this->getToken(); 23 | $ch = curl_init($url); 24 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 25 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json')); 26 | curl_setopt($ch, CURLOPT_POST, 1); 27 | curl_getinfo($ch); 28 | $response = curl_exec($ch); 29 | return $response; 30 | } 31 | 32 | private function getToken(){ 33 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 34 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 35 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 36 | $response = json_decode(curl_exec($ch)); 37 | curl_close($ch); 38 | $token = $response->access_token; 39 | return $token; 40 | } 41 | } -------------------------------------------------------------------------------- /php/Asset/EmailTemplates/GetEmailTemplateByID.php: -------------------------------------------------------------------------------- 1 | id = 1001; 13 | print_r($emailTemplate->getData()); 14 | 15 | 16 | class GetEmailTemplate{ 17 | private $host = "CHANGE ME"; 18 | private $clientId = "CHANGE ME"; 19 | private $clientSecret = "CHANGE ME"; 20 | public $id; //id of the template to retrieve, required 21 | public $status; //optional status filter 22 | 23 | public function getData(){ 24 | $url = $this->host . "/rest/asset/v1/emailTemplate/" . $this->id . ".json?access_token=" . $this->getToken(); 25 | if (isset($this->status)){ 26 | $url .= "&status=" . $this->status; 27 | } 28 | $ch = curl_init($url); 29 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 30 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 31 | $response = curl_exec($ch); 32 | return $response; 33 | } 34 | 35 | private function getToken(){ 36 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 37 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 38 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json')); 39 | $response = json_decode(curl_exec($ch)); 40 | curl_close($ch); 41 | $token = $response->access_token; 42 | return $token; 43 | } 44 | } -------------------------------------------------------------------------------- /php/Asset/EmailTemplates/GetEmailTemplateByName.php: -------------------------------------------------------------------------------- 1 | name = "Sample Template - PHP"; 13 | print_r($emailTemplate->getData()); 14 | 15 | 16 | class EmailTemplateByName{ 17 | private $host = "CHANGE ME"; 18 | private $clientId = "CHANGE ME"; 19 | private $clientSecret = "CHANGE ME"; 20 | public $name;//name of template to retrieve 21 | public $status; //optional status filter 22 | 23 | public function getData(){ 24 | $url = $this->host . "/rest/asset/v1/emailTemplate/byName.json?access_token=" . $this->getToken() . "&name=" . $this->name; 25 | if (isset($this->status)){ 26 | $url .= "&status=" . $this->status; 27 | } 28 | $ch = curl_init($url); 29 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 30 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 31 | $response = curl_exec($ch); 32 | return $response; 33 | } 34 | 35 | private function getToken(){ 36 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 37 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 38 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json')); 39 | $response = json_decode(curl_exec($ch)); 40 | curl_close($ch); 41 | $token = $response->access_token; 42 | return $token; 43 | } 44 | } -------------------------------------------------------------------------------- /php/Asset/EmailTemplates/GetEmailTemplateContentByID.php: -------------------------------------------------------------------------------- 1 | id = 1037; 13 | print_r($content->getData()); 14 | 15 | class GetEmailTemplateContent{ 16 | private $host = "CHANGE ME"; 17 | private $clientId = "CHANGE ME"; 18 | private $clientSecret = "CHANGE ME"; 19 | public $id;//id of template to retrieve content from 20 | public $status;//optional status filter 21 | 22 | public function getData(){ 23 | $url = $this->host . "/rest/asset/v1/emailTemplate/" . $this->id . "/content?access_token=" . $this->getToken(); 24 | if (isset($this->status)){ 25 | $url .= "&status=" . $this->status; 26 | } 27 | $ch = curl_init($url); 28 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 29 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 30 | $response = curl_exec($ch); 31 | return $response; 32 | } 33 | 34 | private function getToken(){ 35 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 36 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 37 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json')); 38 | $response = json_decode(curl_exec($ch)); 39 | curl_close($ch); 40 | $token = $response->access_token; 41 | return $token; 42 | } 43 | } -------------------------------------------------------------------------------- /php/Asset/EmailTemplates/UnapproveEmailTemplateDraft.php: -------------------------------------------------------------------------------- 1 | id = 1; 13 | print_r($clone->postData()); 14 | 15 | class UnapproveEmailTemplate{ 16 | private $host = "CHANGE ME"; 17 | private $clientId = "CHANGE ME"; 18 | private $clientSecret = "CHANGE ME"; 19 | public $id; //id of template to delete 20 | 21 | public function postData(){ 22 | $url = $this->host . "/rest/asset/v1/emailTemplate/" . $this->id . "/unapprove.json?access_token=" . $this->getToken(); 23 | $ch = curl_init($url); 24 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 25 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json')); 26 | curl_setopt($ch, CURLOPT_POST, 1); 27 | curl_getinfo($ch); 28 | $response = curl_exec($ch); 29 | return $response; 30 | } 31 | 32 | private function getToken(){ 33 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 34 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 35 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 36 | $response = json_decode(curl_exec($ch)); 37 | curl_close($ch); 38 | $token = $response->access_token; 39 | return $token; 40 | } 41 | } -------------------------------------------------------------------------------- /php/Asset/Emails/ApproveEmailDraft.php: -------------------------------------------------------------------------------- 1 | id = 1; 13 | print_r($approve->postData()); 14 | 15 | class ApproveEmail{ 16 | private $host = "CHANGE ME"; 17 | private $clientId = "CHANGE ME"; 18 | private $clientSecret = "CHANGE ME"; 19 | public $id; //id of to delete 20 | 21 | public function postData(){ 22 | $url = $this->host . "/rest/asset/v1/email/" . $this->id . "/approveDraft.json?access_token=" . $this->getToken(); 23 | $ch = curl_init($url); 24 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 25 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json')); 26 | curl_setopt($ch, CURLOPT_POST, 1); 27 | curl_getinfo($ch); 28 | $response = curl_exec($ch); 29 | return $response; 30 | } 31 | 32 | private function getToken(){ 33 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 34 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 35 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 36 | $response = json_decode(curl_exec($ch)); 37 | curl_close($ch); 38 | $token = $response->access_token; 39 | return $token; 40 | } 41 | } -------------------------------------------------------------------------------- /php/Asset/Emails/DeleteEmail.php: -------------------------------------------------------------------------------- 1 | id = 1; 13 | print_r($delete->postData()); 14 | 15 | class DeleteEmail{ 16 | private $host = "CHANGE ME"; 17 | private $clientId = "CHANGE ME"; 18 | private $clientSecret = "CHANGE ME"; 19 | public $id; //id of to delete 20 | 21 | public function postData(){ 22 | $url = $this->host . "/rest/asset/v1/email/" . $this->id . "/delete.json?access_token=" . $this->getToken(); 23 | $ch = curl_init($url); 24 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 25 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json')); 26 | curl_setopt($ch, CURLOPT_POST, 1); 27 | curl_getinfo($ch); 28 | $response = curl_exec($ch); 29 | return $response; 30 | } 31 | 32 | private function getToken(){ 33 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 34 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 35 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 36 | $response = json_decode(curl_exec($ch)); 37 | curl_close($ch); 38 | $token = $response->access_token; 39 | return $token; 40 | } 41 | } -------------------------------------------------------------------------------- /php/Asset/Emails/DiscardEmailDraft.php: -------------------------------------------------------------------------------- 1 | id = 1; 13 | print_r($clone->postData()); 14 | 15 | class DiscardEmailDraft{ 16 | private $host = "CHANGE ME"; 17 | private $clientId = "CHANGE ME"; 18 | private $clientSecret = "CHANGE ME"; 19 | public $id; //id of to delete 20 | 21 | public function postData(){ 22 | $url = $this->host . "/rest/asset/v1/email/" . $this->id . "/discardDraft.json?access_token=" . $this->getToken(); 23 | $ch = curl_init($url); 24 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 25 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json')); 26 | curl_setopt($ch, CURLOPT_POST, 1); 27 | curl_getinfo($ch); 28 | $response = curl_exec($ch); 29 | return $response; 30 | } 31 | 32 | private function getToken(){ 33 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 34 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 35 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 36 | $response = json_decode(curl_exec($ch)); 37 | curl_close($ch); 38 | $token = $response->access_token; 39 | return $token; 40 | } 41 | } -------------------------------------------------------------------------------- /php/Asset/Emails/GetEmailByID.php: -------------------------------------------------------------------------------- 1 | id = 1001; 13 | print_r($email->getData()); 14 | 15 | 16 | class GetEmail{ 17 | private $host = "CHANGE ME"; 18 | private $clientId = "CHANGE ME"; 19 | private $clientSecret = "CHANGE ME"; 20 | public $id; //id of the to retrieve, required 21 | public $status; //optional status filter 22 | 23 | public function getData(){ 24 | $url = $this->host . "/rest/asset/v1/email/" . $this->id . ".json?access_token=" . $this->getToken(); 25 | if (isset($this->status)){ 26 | $url .= "&status=" . $this->status; 27 | } 28 | $ch = curl_init($url); 29 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 30 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 31 | $response = curl_exec($ch); 32 | return $response; 33 | } 34 | 35 | private function getToken(){ 36 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 37 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 38 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json')); 39 | $response = json_decode(curl_exec($ch)); 40 | curl_close($ch); 41 | $token = $response->access_token; 42 | return $token; 43 | } 44 | } -------------------------------------------------------------------------------- /php/Asset/Emails/GetEmailByName.php: -------------------------------------------------------------------------------- 1 | name = "Sample - PHP"; 13 | print_r($email->getData()); 14 | 15 | 16 | class EmailByName{ 17 | private $host = "CHANGE ME"; 18 | private $clientId = "CHANGE ME"; 19 | private $clientSecret = "CHANGE ME"; 20 | public $name;//name of to retrieve 21 | public $status; //optional status filter 22 | 23 | public function getData(){ 24 | $url = $this->host . "/rest/asset/v1/email/byName.json?access_token=" . $this->getToken() . "&name=" . $this->name; 25 | if (isset($this->status)){ 26 | $url .= "&status=" . $this->status; 27 | } 28 | $ch = curl_init($url); 29 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 30 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 31 | $response = curl_exec($ch); 32 | return $response; 33 | } 34 | 35 | private function getToken(){ 36 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 37 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 38 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json')); 39 | $response = json_decode(curl_exec($ch)); 40 | curl_close($ch); 41 | $token = $response->access_token; 42 | return $token; 43 | } 44 | } -------------------------------------------------------------------------------- /php/Asset/Emails/GetEmailContent.php: -------------------------------------------------------------------------------- 1 | id = 1211; 13 | print_r($content->getData()); 14 | 15 | class GetEmailContent{ 16 | private $host = "CHANGE ME"; 17 | private $clientId = "CHANGE ME"; 18 | private $clientSecret = "CHANGE ME"; 19 | public $id;//id of to retrieve content from 20 | public $status;//optional status filter 21 | 22 | public function getData(){ 23 | $url = $this->host . "/rest/asset/v1/email/" . $this->id . "/content.json?access_token=" . $this->getToken(); 24 | if (isset($this->status)){ 25 | $url .= "&status=" . $this->status; 26 | } 27 | $ch = curl_init($url); 28 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 29 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 30 | $response = curl_exec($ch); 31 | return $response; 32 | } 33 | 34 | private function getToken(){ 35 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 36 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 37 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json')); 38 | $response = json_decode(curl_exec($ch)); 39 | curl_close($ch); 40 | $token = $response->access_token; 41 | return $token; 42 | } 43 | } -------------------------------------------------------------------------------- /php/Asset/Emails/UnapproveEmail.php: -------------------------------------------------------------------------------- 1 | id = 1; 13 | print_r($clone->postData()); 14 | 15 | class UnapproveEmail{ 16 | private $host = "CHANGE ME"; 17 | private $clientId = "CHANGE ME"; 18 | private $clientSecret = "CHANGE ME"; 19 | public $id; //id of to delete 20 | 21 | public function postData(){ 22 | $url = $this->host . "/rest/asset/v1/email/" . $this->id . "/unapprove.json?access_token=" . $this->getToken(); 23 | $ch = curl_init($url); 24 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 25 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json')); 26 | curl_setopt($ch, CURLOPT_POST, 1); 27 | curl_getinfo($ch); 28 | $response = curl_exec($ch); 29 | return $response; 30 | } 31 | 32 | private function getToken(){ 33 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 34 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 35 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 36 | $response = json_decode(curl_exec($ch)); 37 | curl_close($ch); 38 | $token = $response->access_token; 39 | return $token; 40 | } 41 | } -------------------------------------------------------------------------------- /php/Asset/Files/GetFileByID.php: -------------------------------------------------------------------------------- 1 | id = 13824; 13 | print_r($file->getData()); 14 | 15 | class GetFile{ 16 | private $host = "CHANGE ME"; 17 | private $clientId = "CHANGE ME"; 18 | private $clientSecret = "CHANGE ME"; 19 | public $id;//id of file to retrieve 20 | 21 | public function getData(){ 22 | $url = $this->host . "/rest/asset/v1/file/" . $this->id . ".json?access_token=" . $this->getToken(); 23 | $ch = curl_init($url); 24 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 25 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 26 | $response = curl_exec($ch); 27 | return $response; 28 | } 29 | 30 | private function getToken(){ 31 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 32 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 33 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json')); 34 | $response = json_decode(curl_exec($ch)); 35 | curl_close($ch); 36 | $token = $response->access_token; 37 | return $token; 38 | } 39 | } -------------------------------------------------------------------------------- /php/Asset/Files/GetFileByName.php: -------------------------------------------------------------------------------- 1 | host . "/rest/asset/v1/file/byName.json?access_token=" . $this->getToken() . "&name=" . $this->name; 20 | $ch = curl_init($url); 21 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 22 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 23 | $response = curl_exec($ch); 24 | return $response; 25 | } 26 | 27 | private function getToken(){ 28 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 29 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 30 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json')); 31 | $response = json_decode(curl_exec($ch)); 32 | curl_close($ch); 33 | $token = $response->access_token; 34 | return $token; 35 | } 36 | } -------------------------------------------------------------------------------- /php/Asset/Folders/DeleteFolder.php: -------------------------------------------------------------------------------- 1 | type = "Folder"; 13 | $folder->id = 5565; 14 | print_r($folder->postData()); 15 | 16 | class DeleteFolder{ 17 | private $host = "CHANGE ME"; 18 | private $clientId = "CHANGE ME"; 19 | private $clientSecret = "CHANGE ME"; 20 | public $id;//id of folder to update, required 21 | public $type;//type of folder, Folder or Program, required 22 | 23 | public function postData(){ 24 | $url = $this->host . "/rest/asset/v1/folder/" . $this->id . ".json?access_token=" . $this->getToken() . "&type=" . $this->type; 25 | $ch = curl_init($url); 26 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 27 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json')); 28 | curl_setopt($ch, CURLOPT_POST, 1); 29 | curl_getinfo($ch); 30 | $response = curl_exec($ch); 31 | return $response; 32 | } 33 | 34 | private function getToken(){ 35 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 36 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 37 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 38 | $response = json_decode(curl_exec($ch)); 39 | curl_close($ch); 40 | $token = $response->access_token; 41 | return $token; 42 | } 43 | } -------------------------------------------------------------------------------- /php/Asset/Folders/GetFolderByID.php: -------------------------------------------------------------------------------- 1 | id = 5566; 13 | $folder->type = "Folder"; 14 | print_r($folder->getData()); 15 | 16 | class Folder{ 17 | private $host = "CHANGE ME"; 18 | private $clientId = "CHANGE ME"; 19 | private $clientSecret = "CHANGE ME"; 20 | public $id; //integer id of folder to retrieve, required 21 | public $type; //type to retrieve, Folder or Program, required 22 | 23 | public function getData(){ 24 | $url = $this->host . "/rest/asset/v1/folder/" . $this->id . ".json?access_token=" . $this->getToken() . "&type=" . $this->type; 25 | $ch = curl_init($url); 26 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 27 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 28 | $response = curl_exec($ch); 29 | return $response; 30 | } 31 | 32 | private function getToken(){ 33 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 34 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 35 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 36 | $response = json_decode(curl_exec($ch)); 37 | curl_close($ch); 38 | $token = $response->access_token; 39 | return $token; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /php/Asset/LandingPageTemplates/GetLandingPageTemplateContent.php: -------------------------------------------------------------------------------- 1 | id = 1037; 13 | print_r($content->getData()); 14 | 15 | class GetLandingPageTemplateContent{ 16 | private $host = "CHANGE ME"; 17 | private $clientId = "CHANGE ME"; 18 | private $clientSecret = "CHANGE ME"; 19 | public $id;//id of template to retrieve content from 20 | public $status;//optional status filter 21 | 22 | public function getData(){ 23 | $url = $this->host . "/rest/asset/v1/landingPageTemplate/" . $this->id . "/content?access_token=" . $this->getToken(); 24 | if (isset($this->status)){ 25 | $url .= "&status=" . $this->status; 26 | } 27 | $ch = curl_init($url); 28 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 29 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 30 | $response = curl_exec($ch); 31 | return $response; 32 | } 33 | 34 | private function getToken(){ 35 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 36 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 37 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json')); 38 | $response = json_decode(curl_exec($ch)); 39 | curl_close($ch); 40 | $token = $response->access_token; 41 | return $token; 42 | } 43 | } 44 | 45 | -------------------------------------------------------------------------------- /php/Asset/Programs/ApproveProgram.php: -------------------------------------------------------------------------------- 1 | id = 1001; 14 | print_r($program->postData()); 15 | 16 | class ApproveProgram{ 17 | private $host = "CHANGE ME"; 18 | private $clientId = "CHANGE ME"; 19 | private $clientSecret = "CHANGE ME"; 20 | 21 | public $id;//id of email program to approve 22 | 23 | public function postData(){ 24 | $url = $this->host . "/rest/asset/v1/program/" . $this->id . "/approve.json"; 25 | $ch = curl_init($url); 26 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 27 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json', "Authorization: Bearer " . $this->getToken())); 28 | curl_setopt($ch, CURLOPT_POST, 1); 29 | curl_getinfo($ch); 30 | $response = curl_exec($ch); 31 | return $response; 32 | } 33 | 34 | private function getToken(){ 35 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 36 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 37 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 38 | $response = json_decode(curl_exec($ch)); 39 | curl_close($ch); 40 | $token = $response->access_token; 41 | return $token; 42 | } 43 | 44 | } -------------------------------------------------------------------------------- /php/Asset/Programs/DeleteProgram.php: -------------------------------------------------------------------------------- 1 | id = 1001; 14 | print_r($program->postData()); 15 | 16 | class DeleteProgram{ 17 | private $host = "CHANGE ME"; 18 | private $clientId = "CHANGE ME"; 19 | private $clientSecret = "CHANGE ME"; 20 | 21 | public $id;//id of program to delete 22 | 23 | public function postData(){ 24 | $url = $this->host . "/rest/asset/v1/program/" . $this->id . "/delete.json"; 25 | $ch = curl_init($url); 26 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 27 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json', "Authorization: Bearer " . $this->getToken())); 28 | curl_setopt($ch, CURLOPT_POST, 1); 29 | curl_getinfo($ch); 30 | $response = curl_exec($ch); 31 | return $response; 32 | } 33 | 34 | private function getToken(){ 35 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 36 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 37 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 38 | $response = json_decode(curl_exec($ch)); 39 | curl_close($ch); 40 | $token = $response->access_token; 41 | return $token; 42 | } 43 | } -------------------------------------------------------------------------------- /php/Asset/Programs/GetProgramByID.php: -------------------------------------------------------------------------------- 1 | id = 1001; 13 | 14 | print_r($program->getData()); 15 | 16 | class GetProgramById{ 17 | private $host = "CHANGE ME"; 18 | private $clientId = "CHANGE ME"; 19 | private $clientSecret = "CHANGE ME"; 20 | 21 | public $id;//id of the program to retrieve 22 | 23 | public function getData(){ 24 | $url = $this->host . "/rest/asset/v1/program/" . $this->id . ".json"; 25 | $ch = curl_init($url); 26 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 27 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json', "Authorization: Bearer " . $this->getToken())); 28 | $response = curl_exec($ch); 29 | return $response; 30 | } 31 | 32 | private function getToken(){ 33 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 34 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 35 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 36 | $response = json_decode(curl_exec($ch)); 37 | curl_close($ch); 38 | $token = $response->access_token; 39 | return $token; 40 | } 41 | } -------------------------------------------------------------------------------- /php/Asset/Programs/GetProgramByName.php: -------------------------------------------------------------------------------- 1 | name = "Test Program Name"; 13 | 14 | print_r($program->getData()); 15 | 16 | class GetProgramByName{ 17 | private $host = "CHANGE ME"; 18 | private $clientId = "CHANGE ME"; 19 | private $clientSecret = "CHANGE ME"; 20 | 21 | public $name;//name of the program to retrieve 22 | 23 | public function getData(){ 24 | $url = $this->host . "/rest/asset/v1/program/byName.json?name=" . $this->name; 25 | $ch = curl_init($url); 26 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 27 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json', "Authorization: Bearer " . $this->getToken())); 28 | $response = curl_exec($ch); 29 | return $response; 30 | } 31 | 32 | private function getToken(){ 33 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 34 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 35 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 36 | $response = json_decode(curl_exec($ch)); 37 | curl_close($ch); 38 | $token = $response->access_token; 39 | return $token; 40 | } 41 | } -------------------------------------------------------------------------------- /php/Asset/Programs/GetProgramsByTag.php: -------------------------------------------------------------------------------- 1 | tagType = "Presenter"; 13 | $program->tagValue = "David"; 14 | 15 | print_r($program->getData()); 16 | 17 | class GetProgramsByTag{ 18 | private $host = "CHANGE ME"; 19 | private $clientId = "CHANGE ME"; 20 | private $clientSecret = "CHANGE ME"; 21 | 22 | public $name;//name of the program to retrieve 23 | 24 | public function getData(){ 25 | $url = $this->host . "/rest/asset/v1/program/byTag.json?tagType=" . this.tagType . "&tagValue=" . this.tagValue; 26 | $ch = curl_init($url); 27 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 28 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json', "Authorization: Bearer " . $this->getToken())); 29 | $response = curl_exec($ch); 30 | return $response; 31 | } 32 | 33 | private function getToken(){ 34 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 35 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 36 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 37 | $response = json_decode(curl_exec($ch)); 38 | curl_close($ch); 39 | $token = $response->access_token; 40 | return $token; 41 | } 42 | } -------------------------------------------------------------------------------- /php/Asset/Programs/UnapproveProgram.php: -------------------------------------------------------------------------------- 1 | id = 1001; 14 | print_r($program->postData()); 15 | 16 | class UnapproveProgram{ 17 | private $host = "CHANGE ME"; 18 | private $clientId = "CHANGE ME"; 19 | private $clientSecret = "CHANGE ME"; 20 | 21 | public $id;//id of email program to approve 22 | 23 | public function postData(){ 24 | $url = $this->host . "/rest/asset/v1/program/" . $this->id . "/unapprove.json"; 25 | $ch = curl_init($url); 26 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 27 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json', "Authorization: Bearer " . $this->getToken())); 28 | curl_setopt($ch, CURLOPT_POST, 1); 29 | curl_getinfo($ch); 30 | $response = curl_exec($ch); 31 | return $response; 32 | } 33 | 34 | private function getToken(){ 35 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 36 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 37 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 38 | $response = json_decode(curl_exec($ch)); 39 | curl_close($ch); 40 | $token = $response->access_token; 41 | return $token; 42 | } 43 | 44 | } -------------------------------------------------------------------------------- /php/Asset/Segments/GetSegmentations.php: -------------------------------------------------------------------------------- 1 | getData()); 13 | 14 | class GetSegmentations{ 15 | private $host = "CHANGE ME"; 16 | private $clientId = "CHANGE ME"; 17 | private $clientSecret = "CHANGE ME"; 18 | 19 | public function getData(){ 20 | $url = $this->host . "/rest/asset/v1/segmentation.json?access_token=" . $this->getToken(); 21 | $ch = curl_init($url); 22 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 23 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 24 | $response = curl_exec($ch); 25 | return $response; 26 | } 27 | 28 | private function getToken(){ 29 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 30 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 31 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json')); 32 | $response = json_decode(curl_exec($ch)); 33 | curl_close($ch); 34 | $token = $response->access_token; 35 | return $token; 36 | } 37 | } -------------------------------------------------------------------------------- /php/Asset/Segments/GetSegmentsForSegmentations.php: -------------------------------------------------------------------------------- 1 | id = 1002; 13 | print_r($segments->getData()); 14 | 15 | class GetSegments{ 16 | private $host = "CHANGE ME"; 17 | private $clientId = "CHANGE ME"; 18 | private $clientSecret = "CHANGE ME"; 19 | public $id;//id of sementation to retrieve segments from 20 | 21 | public function getData(){ 22 | $url = $this->host . "/rest/asset/v1/segmentation/" . $this->id . "/segments.json?access_token=" . $this->getToken(); 23 | $ch = curl_init($url); 24 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 25 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 26 | $response = curl_exec($ch); 27 | return $response; 28 | } 29 | 30 | private function getToken(){ 31 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 32 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 33 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json')); 34 | $response = json_decode(curl_exec($ch)); 35 | curl_close($ch); 36 | $token = $response->access_token; 37 | return $token; 38 | } 39 | } -------------------------------------------------------------------------------- /php/Asset/Snippets/ApproveSnippetDraft.php: -------------------------------------------------------------------------------- 1 | id = 1; 13 | print_r($approve->postData()); 14 | 15 | class ApproveSnippet{ 16 | private $host = "CHANGE ME"; 17 | private $clientId = "CHANGE ME"; 18 | private $clientSecret = "CHANGE ME"; 19 | public $id; //id of snippet to approve 20 | 21 | public function postData(){ 22 | $url = $this->host . "/rest/asset/v1/snippet/" . $this->id . "/approveDraft.json?access_token=" . $this->getToken(); 23 | $ch = curl_init($url); 24 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 25 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json')); 26 | curl_setopt($ch, CURLOPT_POST, 1); 27 | curl_getinfo($ch); 28 | $response = curl_exec($ch); 29 | return $response; 30 | } 31 | 32 | private function getToken(){ 33 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 34 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 35 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 36 | $response = json_decode(curl_exec($ch)); 37 | curl_close($ch); 38 | $token = $response->access_token; 39 | return $token; 40 | } 41 | } -------------------------------------------------------------------------------- /php/Asset/Snippets/DeleteSnippet.php: -------------------------------------------------------------------------------- 1 | id = 1; 13 | print_r($delete->postData()); 14 | 15 | class DeleteSnippet{ 16 | private $host = "CHANGE ME"; 17 | private $clientId = "CHANGE ME"; 18 | private $clientSecret = "CHANGE ME"; 19 | public $id; //id of snippet to delete 20 | 21 | public function postData(){ 22 | $url = $this->host . "/rest/asset/v1/snippet/" . $this->id . "/delete.json?access_token=" . $this->getToken(); 23 | $ch = curl_init($url); 24 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 25 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json')); 26 | curl_setopt($ch, CURLOPT_POST, 1); 27 | curl_getinfo($ch); 28 | $response = curl_exec($ch); 29 | return $response; 30 | } 31 | 32 | private function getToken(){ 33 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 34 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 35 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 36 | $response = json_decode(curl_exec($ch)); 37 | curl_close($ch); 38 | $token = $response->access_token; 39 | return $token; 40 | } 41 | } -------------------------------------------------------------------------------- /php/Asset/Snippets/DiscardSnippetDraft.php: -------------------------------------------------------------------------------- 1 | id = 1; 13 | print_r($clone->postData()); 14 | 15 | class DiscardSnippetDraft{ 16 | private $host = "CHANGE ME"; 17 | private $clientId = "CHANGE ME"; 18 | private $clientSecret = "CHANGE ME"; 19 | public $id; //id of snippet with draft to discard 20 | 21 | public function postData(){ 22 | $url = $this->host . "/rest/asset/v1/snippet/" . $this->id . "/discardDraft.json?access_token=" . $this->getToken(); 23 | $ch = curl_init($url); 24 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 25 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json')); 26 | curl_setopt($ch, CURLOPT_POST, 1); 27 | curl_getinfo($ch); 28 | $response = curl_exec($ch); 29 | return $response; 30 | } 31 | 32 | private function getToken(){ 33 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 34 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 35 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 36 | $response = json_decode(curl_exec($ch)); 37 | curl_close($ch); 38 | $token = $response->access_token; 39 | return $token; 40 | } 41 | } -------------------------------------------------------------------------------- /php/Asset/Snippets/GetSnippetByID.php: -------------------------------------------------------------------------------- 1 | id = 7; 13 | print_r($snippet->getData()); 14 | 15 | 16 | class GetSnippet{ 17 | private $host = "CHANGE ME"; 18 | private $clientId = "CHANGE ME"; 19 | private $clientSecret = "CHANGE ME"; 20 | public $id; //id of the to retrieve, required 21 | public $status; //optional status filter 22 | 23 | public function getData(){ 24 | $url = $this->host . "/rest/asset/v1/snippet/" . $this->id . ".json?access_token=" . $this->getToken(); 25 | if (isset($this->status)){ 26 | $url .= "&status=" . $this->status; 27 | } 28 | $ch = curl_init($url); 29 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 30 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 31 | $response = curl_exec($ch); 32 | return $response; 33 | } 34 | 35 | private function getToken(){ 36 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 37 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 38 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json')); 39 | $response = json_decode(curl_exec($ch)); 40 | curl_close($ch); 41 | $token = $response->access_token; 42 | return $token; 43 | } 44 | } -------------------------------------------------------------------------------- /php/Asset/Snippets/GetSnippetContent.php: -------------------------------------------------------------------------------- 1 | id = 3; 13 | print_r($content->getData()); 14 | 15 | class GetsnippetContent{ 16 | private $host = "CHANGE ME"; 17 | private $clientId = "CHANGE ME"; 18 | private $clientSecret = "CHANGE ME"; 19 | public $id;//id of to retrieve content from 20 | 21 | public function getData(){ 22 | $url = $this->host . "/rest/asset/v1/snippet/" . $this->id . "/content.json?access_token=" . $this->getToken(); 23 | $ch = curl_init($url); 24 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 25 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 26 | $response = curl_exec($ch); 27 | return $response; 28 | } 29 | 30 | private function getToken(){ 31 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 32 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 33 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json')); 34 | $response = json_decode(curl_exec($ch)); 35 | curl_close($ch); 36 | $token = $response->access_token; 37 | return $token; 38 | } 39 | } -------------------------------------------------------------------------------- /php/Asset/Snippets/UnapproveSnippet.php: -------------------------------------------------------------------------------- 1 | id = 1; 13 | print_r($clone->postData()); 14 | 15 | class UnapproveSnippet{ 16 | private $host = "CHANGE ME"; 17 | private $clientId = "CHANGE ME"; 18 | private $clientSecret = "CHANGE ME"; 19 | public $id; //id of snippet to unapprove 20 | 21 | public function postData(){ 22 | $url = $this->host . "/rest/asset/v1/snippet/" . $this->id . "/unapprove.json?access_token=" . $this->getToken(); 23 | $ch = curl_init($url); 24 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 25 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json')); 26 | curl_setopt($ch, CURLOPT_POST, 1); 27 | curl_getinfo($ch); 28 | $response = curl_exec($ch); 29 | return $response; 30 | } 31 | 32 | private function getToken(){ 33 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 34 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 35 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 36 | $response = json_decode(curl_exec($ch)); 37 | curl_close($ch); 38 | $token = $response->access_token; 39 | return $token; 40 | } 41 | } -------------------------------------------------------------------------------- /php/Asset/Tags/GetTagByName.php: -------------------------------------------------------------------------------- 1 | name = "Presenter"; 14 | print_r($tag->getData()); 15 | 16 | class GetTagByName{ 17 | private $host = "CHANGE ME"; 18 | private $clientId = "CHANGE ME"; 19 | private $clientSecret = "CHANGE ME"; 20 | 21 | public $name;//name of tag to retrieve 22 | 23 | public function getData(){ 24 | $url = $this->host . "/rest/asset/v1/tagType/byName.json?name=$this->name"; 25 | $ch = curl_init($url); 26 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 27 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json', "Authorization: Bearer " . $this->getToken())); 28 | $response = curl_exec($ch); 29 | return $response; 30 | } 31 | 32 | private function getToken(){ 33 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 34 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 35 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 36 | $response = json_decode(curl_exec($ch)); 37 | curl_close($ch); 38 | $token = $response->access_token; 39 | return $token; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /php/Asset/Tags/GetTagTypes.php: -------------------------------------------------------------------------------- 1 | getData()); 14 | 15 | class GetTags{ 16 | private $host = "CHANGE ME"; 17 | private $clientId = "CHANGE ME"; 18 | private $clientSecret = "CHANGE ME"; 19 | 20 | public $offset;//integer offset for paging 21 | public $maxReturn;//max number of records to return 22 | 23 | public function getData(){ 24 | $url = $this->host . "/rest/asset/v1/tagTypes.json?"; 25 | if(isset($this->offset)){ 26 | $url .= "offset=$this->offset&"; 27 | } 28 | if(isset($this->maxReturn)){ 29 | $url .= "maxReturn=$this->maxReturn"; 30 | } 31 | $ch = curl_init($url); 32 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 33 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json', "Authorization: Bearer " . $this->getToken())); 34 | $response = curl_exec($ch); 35 | return $response; 36 | } 37 | 38 | private function getToken(){ 39 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 40 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 41 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 42 | $response = json_decode(curl_exec($ch)); 43 | curl_close($ch); 44 | $token = $response->access_token; 45 | return $token; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /php/Asset/Tokens/GetTokensByFolderID.php: -------------------------------------------------------------------------------- 1 | id = 1071; 13 | $tokens->folderType = "Program"; 14 | print_r($tokens->getData()); 15 | 16 | class GetTokens{ 17 | private $host = "CHANGE ME"; 18 | private $clientId = "CHANGE ME"; 19 | private $clientSecret = "CHANGE ME"; 20 | public $id;//id of folder to retrieve from 21 | public $folderType;//type of folder, Folder or Program 22 | 23 | public function getData(){ 24 | $url = $this->host . "/rest/asset/v1/folder/" . $this->id . "/tokens.json?access_token=" . $this->getToken() . "&folderType=" . $this->folderType; 25 | $ch = curl_init($url); 26 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 27 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json')); 28 | $response = curl_exec($ch); 29 | return $response; 30 | } 31 | 32 | private function getToken(){ 33 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 34 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 35 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 36 | $response = json_decode(curl_exec($ch)); 37 | curl_close($ch); 38 | $token = $response->access_token; 39 | return $token; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /php/LeadDatabase/Activities/GetActivityTypes.php: -------------------------------------------------------------------------------- 1 | getData()); 13 | 14 | class GetActivityTypes{ 15 | private $host = "CHANGE ME"; 16 | private $clientId = "CHANGE ME"; 17 | private $clientSecret = "CHANGE ME"; 18 | 19 | public function getData(){ 20 | $url = $this->host . "/rest/v1/activities/types.json?access_token=" . $this->getToken(); 21 | $ch = curl_init($url); 22 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 23 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 24 | $response = curl_exec($ch); 25 | return $response; 26 | } 27 | 28 | private function getToken(){ 29 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 30 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 31 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 32 | $response = json_decode(curl_exec($ch)); 33 | curl_close($ch); 34 | $token = $response->access_token; 35 | return $token; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /php/LeadDatabase/Activities/GetPagingToken.php: -------------------------------------------------------------------------------- 1 | sinceDatetime = "2015-01-01T00:00:00z"; 13 | print_r($pagingToken->getData()); 14 | 15 | 16 | class GetPagingToken{ 17 | private $host = "CHANGE ME"; 18 | private $clientId = "CHANGE ME"; 19 | private $clientSecret = "CHANGE ME"; 20 | public $sinceDatetime;//earliest time to retrieve data from 21 | 22 | public function getData(){ 23 | $url = $this->host . "/rest/v1/activities/pagingtoken.json?access_token=" . $this->getToken() . "&sinceDatetime=" . $this->sinceDatetime; 24 | $ch = curl_init($url); 25 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 26 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 27 | $response = curl_exec($ch); 28 | return $response; 29 | } 30 | 31 | private function getToken(){ 32 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 33 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 34 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 35 | $response = json_decode(curl_exec($ch)); 36 | curl_close($ch); 37 | $token = $response->access_token; 38 | return $token; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /php/LeadDatabase/BulkLeads/GetImportLeadFailures.php: -------------------------------------------------------------------------------- 1 | id = 1336; 13 | print_r($status->getData()); 14 | 15 | class GetImportFailures{ 16 | private $host = "CHANGE ME"; 17 | private $clientId = "CHANGE ME"; 18 | private $clientSecret = "CHANGE ME"; 19 | public $id;//id of batch returned by import leads call 20 | 21 | public function getData(){ 22 | $url = $this->host . "/bulk/v1/leads/batch/" . $this->id . "/failures.json?access_token=" . $this->getToken(); 23 | print_r($url); 24 | $ch = curl_init($url); 25 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 26 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json')); 27 | $response = curl_exec($ch); 28 | return $response; 29 | } 30 | 31 | private function getToken(){ 32 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 33 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 34 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 35 | $response = json_decode(curl_exec($ch)); 36 | curl_close($ch); 37 | $token = $response->access_token; 38 | return $token; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /php/LeadDatabase/BulkLeads/GetImportLeadWarnings.php: -------------------------------------------------------------------------------- 1 | id = 1335; 13 | print_r($status->getData()); 14 | 15 | class GetImportWarnings{ 16 | private $host = "CHANGE ME"; 17 | private $clientId = "CHANGE ME"; 18 | private $clientSecret = "CHANGE ME"; 19 | public $id;//id of batch returned by import leads call 20 | 21 | public function getData(){ 22 | $url = $this->host . "/bulk/v1/leads/batch/" . $this->id . "/warnings.json?access_token=" . $this->getToken(); 23 | $ch = curl_init($url); 24 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 25 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json')); 26 | $response = curl_exec($ch); 27 | return $response; 28 | } 29 | 30 | private function getToken(){ 31 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 32 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 33 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 34 | $response = json_decode(curl_exec($ch)); 35 | curl_close($ch); 36 | $token = $response->access_token; 37 | return $token; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /php/LeadDatabase/Campaigns/GetCampaignByID.php: -------------------------------------------------------------------------------- 1 | id = 1001; 13 | print_r($campaign->getData()); 14 | 15 | class Campaign{ 16 | private $host = "CHANGE ME"; 17 | private $clientId = "CHANGE ME"; 18 | private $clientSecret = "CHANGE ME"; 19 | public $id;//id of campaign to retrieve 20 | 21 | public function getData(){ 22 | $url = $this->host . "/rest/v1/campaigns/" . $this->id . ".json?access_token=" . $this->getToken(); 23 | $ch = curl_init($url); 24 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 25 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 26 | $response = curl_exec($ch); 27 | return $response; 28 | } 29 | 30 | private function getToken(){ 31 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 32 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 33 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 34 | $response = json_decode(curl_exec($ch)); 35 | curl_close($ch); 36 | $token = $response->access_token; 37 | return $token; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /php/LeadDatabase/CustomObjects/DescribeCustomObjects.php: -------------------------------------------------------------------------------- 1 | name = "pet"; 13 | print_r($describe->getData()); 14 | 15 | class DescribeCustomObject{ 16 | private $host = "CHANGE ME"; 17 | private $clientId = "CHANGE ME"; 18 | private $clientSecret = "CHANGE ME"; 19 | public $name;//name of custom object, required 20 | 21 | public function getData(){ 22 | $url = $this->host . "/rest/v1/customobjects/" . $this->name . "/describe.json?access_token=" . $this->getToken(); 23 | $ch = curl_init($url); 24 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 25 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 26 | $response = curl_exec($ch); 27 | return $response; 28 | } 29 | 30 | private function getToken(){ 31 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 32 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 33 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json')); 34 | $response = json_decode(curl_exec($ch)); 35 | curl_close($ch); 36 | $token = $response->access_token; 37 | return $token; 38 | } 39 | } -------------------------------------------------------------------------------- /php/LeadDatabase/CustomObjects/ListOfCustomObjects.php: -------------------------------------------------------------------------------- 1 | getData()); 13 | 14 | class ListCustomObjects{ 15 | private $host = "CHANGE ME"; 16 | private $clientId = "CHANGE ME"; 17 | private $clientSecret = "CHANGE ME"; 18 | public $names;//array of custom object names to list 19 | 20 | public function getData(){ 21 | $url = $this->host . "/rest/v1/customobjects.json?access_token=" . $this->getToken(); 22 | if (isset($this->names)){ 23 | $url .= "&names=" . $this::csvString($this->names); 24 | } 25 | $ch = curl_init($url); 26 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 27 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 28 | $response = curl_exec($ch); 29 | return $response; 30 | } 31 | 32 | private function getToken(){ 33 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 34 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 35 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json')); 36 | $response = json_decode(curl_exec($ch)); 37 | curl_close($ch); 38 | $token = $response->access_token; 39 | return $token; 40 | } 41 | private static function csvString($fields){ 42 | $csvString = implode(",", $fields); 43 | return $csvString; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /php/LeadDatabase/Leads/GetLeadByID.php: -------------------------------------------------------------------------------- 1 | id = 1; 13 | print_r($lead->getData()); 14 | 15 | class Lead{ 16 | private $host = "";//CHANGE ME 17 | private $clientId = "";//CHANGE ME 18 | private $clientSecret = "";//CHANGE ME 19 | public $id;//id of lead to return 20 | public $fields;//array of fields to return 21 | 22 | public function getData(){ 23 | $url = $this->host . "/rest/v1/lead/" . $this->id . ".json?access_token=" . $this->getToken(); 24 | $ch = curl_init($url); 25 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 26 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 27 | $response = curl_exec($ch); 28 | return $response; 29 | } 30 | 31 | private function getToken(){ 32 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 33 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 34 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 35 | $response = json_decode(curl_exec($ch)); 36 | curl_close($ch); 37 | $token = $response->access_token; 38 | return $token; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /php/LeadDatabase/Leads/GetLeadPartitions.php: -------------------------------------------------------------------------------- 1 | getData()); 13 | 14 | class LeadPartitions{ 15 | private $host = "CHANGE ME"; 16 | private $clientId = "CHANGE ME"; 17 | private $clientSecret = "CHANGE ME"; 18 | 19 | public function getData(){ 20 | $url = $this->host . "/rest/v1/leads/partitions.json?access_token=" . $this->getToken(); 21 | $ch = curl_init($url); 22 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 23 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 24 | $response = curl_exec($ch); 25 | return $response; 26 | } 27 | private function getToken(){ 28 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 29 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 30 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 31 | $response = json_decode(curl_exec($ch)); 32 | curl_close($ch); 33 | $token = $response->access_token; 34 | return $token; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /php/LeadDatabase/Opportunities/DescribeOpportunityRole.php: -------------------------------------------------------------------------------- 1 | getData()); 13 | 14 | class DescribeOpportunityRole{ 15 | private $host = "CHANGE ME"; 16 | private $clientId = "CHANGE ME"; 17 | private $clientSecret = "CHANGE ME"; 18 | 19 | public function getData(){ 20 | $url = $this->host . "/rest/v1/opportunities/roles/describe.json?access_token=" . $this->getToken(); 21 | $ch = curl_init($url); 22 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 23 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 24 | $response = curl_exec($ch); 25 | return $response; 26 | } 27 | 28 | private function getToken(){ 29 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 30 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 31 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json')); 32 | $response = json_decode(curl_exec($ch)); 33 | curl_close($ch); 34 | $token = $response->access_token; 35 | return $token; 36 | } 37 | } -------------------------------------------------------------------------------- /php/LeadDatabase/SalesPersons/DescribeSalesPersons.php: -------------------------------------------------------------------------------- 1 | getData()); 13 | 14 | class DescribeSalesPerson{ 15 | private $host = "CHANGE ME"; 16 | private $clientId = "CHANGE ME"; 17 | private $clientSecret = "CHANGE ME"; 18 | 19 | public function getData(){ 20 | $url = $this->host . "/rest/v1/salespersons/describe.json?access_token=" . $this->getToken(); 21 | $ch = curl_init($url); 22 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 23 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 24 | $response = curl_exec($ch); 25 | return $response; 26 | } 27 | 28 | private function getToken(){ 29 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 30 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 31 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json')); 32 | $response = json_decode(curl_exec($ch)); 33 | curl_close($ch); 34 | $token = $response->access_token; 35 | return $token; 36 | } 37 | } -------------------------------------------------------------------------------- /php/LeadDatabase/StaticLists/GetListByID.php: -------------------------------------------------------------------------------- 1 | id = 1001; 13 | print_r($list->getData()); 14 | 15 | class ListById{ 16 | private $host = "CHANGE ME"; 17 | private $clientId = "CHANGE ME"; 18 | private $clientSecret = "CHANGE ME"; 19 | public $id;//id of the list to retrieve 20 | 21 | public function getData(){ 22 | $url = $this->host . "/rest/v1/lists/" . $this->id . ".json?access_token=" . $this->getToken(); 23 | $ch = curl_init($url); 24 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 25 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 26 | $response = curl_exec($ch); 27 | return $response; 28 | } 29 | 30 | private function getToken(){ 31 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 32 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 33 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 34 | $response = json_decode(curl_exec($ch)); 35 | curl_close($ch); 36 | $token = $response->access_token; 37 | return $token; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /php/LeadDatabase/Usage/GetDailyErrors.php: -------------------------------------------------------------------------------- 1 | getData()); 13 | 14 | class GetErrors{ 15 | private $host = "CHANGE ME"; 16 | private $clientId = "CHANGE ME"; 17 | private $clientSecret = "CHANGE ME"; 18 | 19 | public function getData(){ 20 | $url = $this->host . "/rest/v1/stats/errors.json?access_token=" . $this->getToken(); 21 | $ch = curl_init($url); 22 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 23 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 24 | $response = curl_exec($ch); 25 | return $response; 26 | } 27 | 28 | private function getToken(){ 29 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 30 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 31 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 32 | $response = json_decode(curl_exec($ch)); 33 | curl_close($ch); 34 | $token = $response->access_token; 35 | return $token; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /php/LeadDatabase/Usage/GetDailyUsage.php: -------------------------------------------------------------------------------- 1 | getData()); 13 | class GetDailyUsage{ 14 | private $host = "CHANGE ME"; 15 | private $clientId = "CHANGE ME"; 16 | private $clientSecret = "CHANGE ME"; 17 | 18 | public function getData(){ 19 | $url = $this->host . "/rest/v1/stats/usage.json?access_token=" . $this->getToken(); 20 | $ch = curl_init($url); 21 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 22 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 23 | $response = curl_exec($ch); 24 | return $response; 25 | } 26 | 27 | private function getToken(){ 28 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 29 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 30 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 31 | $response = json_decode(curl_exec($ch)); 32 | curl_close($ch); 33 | $token = $response->access_token; 34 | return $token; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /php/LeadDatabase/Usage/GetWeeklyErrors.php: -------------------------------------------------------------------------------- 1 | getData()); 13 | 14 | class Get7DaysErrors{ 15 | private $host = "CHANGE ME"; 16 | private $clientId = "CHANGE ME"; 17 | private $clientSecret = "CHANGE ME"; 18 | 19 | public function getData(){ 20 | $url = $this->host . "/rest/v1/stats/errors.json?access_token=" . $this->getToken(); 21 | $ch = curl_init($url); 22 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 23 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 24 | $response = curl_exec($ch); 25 | return $response; 26 | } 27 | 28 | private function getToken(){ 29 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 30 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 31 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 32 | $response = json_decode(curl_exec($ch)); 33 | curl_close($ch); 34 | $token = $response->access_token; 35 | return $token; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /php/LeadDatabase/Usage/GetWeeklyUsage.php: -------------------------------------------------------------------------------- 1 | getData()); 13 | 14 | class Get7DaysUsage{ 15 | private $host = "CHANGE ME"; 16 | private $clientId = "CHANGE ME"; 17 | private $clientSecret = "CHANGE ME"; 18 | 19 | public function getData(){ 20 | $url = $this->host . "/rest/v1/stats/usage/last7days.json?access_token=" . $this->getToken(); 21 | $ch = curl_init($url); 22 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 23 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 24 | $response = curl_exec($ch); 25 | return $response; 26 | } 27 | 28 | private function getToken(){ 29 | $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 30 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 31 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 32 | $response = json_decode(curl_exec($ch)); 33 | curl_close($ch); 34 | $token = $response->access_token; 35 | return $token; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /python/LeadDatabase/Leads/README.md: -------------------------------------------------------------------------------- 1 | # Get Every Lead 2 | ## get_every_lead.py 3 | 4 | This Python script demonstrates the techniques discussed in the blog post [How to Retrieve Every Person (Lead)](http://developers.marketo.com/blog/how-to-retrieve-every-person-lead/) 5 | 6 | This code is not suitable for inclusion in a production system. It would need to be extended to include more error-recovery code and hooks into connected systems. It was developed as a teaching tool and you should implement your own code based on this template. 7 | 8 | You can test this code by providing the Munchkin ID for your target instance and the Client ID & Secret for the Launchpoint service it will use to connect to the API. 9 | 10 | Requirements: 11 | Python 3.8+ (may work with other versions) 12 | [os module](https://docs.python.org/3/library/os.html) 13 | [requests module](https://pypi.org/project/requests/) 14 | Internet connection 15 | Local filesystem -------------------------------------------------------------------------------- /ruby/Asset/EmailTemplates/ApproveEmailTemplateDraft.rb: -------------------------------------------------------------------------------- 1 | # 2 | # ApproveEmailTemplateDraft.rb 3 | # 4 | # Marketo REST API Sample Code 5 | # Copyright (C) 2016 Marketo, Inc. 6 | # 7 | # This software may be modified and distributed under the terms 8 | # of the MIT license. See the LICENSE file for details. 9 | # 10 | require 'rest-client' 11 | require 'json' 12 | 13 | host = "CHANGE ME" 14 | client_id = "CHANGE ME" 15 | client_secret = "CHANGE ME" 16 | 17 | def get_token(host, client_id, client_secret) 18 | url = "#{host}/identity/oauth/token?grant_type=client_credentials&client_id=#{client_id}&client_secret=#{client_secret}" 19 | response = RestClient.get url 20 | json = JSON.parse(response) 21 | return json["access_token"] 22 | end 23 | 24 | id = 1001 #id of template 25 | params = { 26 | :access_token => get_token(host, client_id, client_secret) 27 | } 28 | 29 | response = RestClient.post "#{host}/rest/asset/v1/emailTemplate/#{id}/approveDraft.json", params 30 | 31 | puts response -------------------------------------------------------------------------------- /ruby/Asset/EmailTemplates/CloneEmailTemplate.rb: -------------------------------------------------------------------------------- 1 | # 2 | # CloneEmailTemplate.rb 3 | # 4 | # Marketo REST API Sample Code 5 | # Copyright (C) 2016 Marketo, Inc. 6 | # 7 | # This software may be modified and distributed under the terms 8 | # of the MIT license. See the LICENSE file for details. 9 | # 10 | require 'rest-client' 11 | require 'json' 12 | 13 | host = "CHANGE ME" 14 | client_id = "CHANGE ME" 15 | client_secret = "CHANGE ME" 16 | 17 | def get_token(host, client_id, client_secret) 18 | url = "#{host}/identity/oauth/token?grant_type=client_credentials&client_id=#{client_id}&client_secret=#{client_secret}" 19 | response = RestClient.get url 20 | json = JSON.parse(response) 21 | return json["access_token"] 22 | end 23 | 24 | id = 1001 #id of template 25 | params = { 26 | :access_token => get_token(host, client_id, client_secret), 27 | :name => "Clone Template - Ruby", #name of new template 28 | :folder => JSON.generate({:id => 15, :type => "Folder"}) #new folder for clone 29 | } 30 | 31 | response = RestClient.post "#{host}/rest/asset/v1/emailTemplate/#{id}/clone.json", params 32 | 33 | puts response -------------------------------------------------------------------------------- /ruby/Asset/EmailTemplates/CreateEmailTemplate.rb: -------------------------------------------------------------------------------- 1 | # 2 | # CreateEmailTemplate.rb 3 | # 4 | # Marketo REST API Sample Code 5 | # Copyright (C) 2016 Marketo, Inc. 6 | # 7 | # This software may be modified and distributed under the terms 8 | # of the MIT license. See the LICENSE file for details. 9 | # 10 | require 'rest-client' 11 | require 'json' 12 | 13 | host = "CHANGE ME" 14 | client_id = "CHANGE ME" 15 | client_secret = "CHANGE ME" 16 | 17 | def get_token(host, client_id, client_secret) 18 | url = "#{host}/identity/oauth/token?grant_type=client_credentials&client_id=#{client_id}&client_secret=#{client_secret}" 19 | response = RestClient.get url 20 | json = JSON.parse(response) 21 | return json["access_token"] 22 | end 23 | 24 | access_token = get_token(host, client_id, client_secret) 25 | 26 | 27 | params = { 28 | :name => "new template - Ruby", #name of new template 29 | :folder => JSON.generate({:id => 15, :type => "Folder"}), #folder record as json 30 | :content => File.new("testFile.html"), #HTML content of template 31 | :description => "Email Template created by Ruby" #optional description 32 | } 33 | 34 | RestClient.log = 'stdout' 35 | response = RestClient.post "#{host}/rest/asset/v1/emailTemplates.json?access_token=#{access_token}", params, {:multipart => true} 36 | 37 | puts response -------------------------------------------------------------------------------- /ruby/Asset/EmailTemplates/DeleteEmailTemplate.rb: -------------------------------------------------------------------------------- 1 | # 2 | # DeleteEmailTemplate.rb 3 | # 4 | # Marketo REST API Sample Code 5 | # Copyright (C) 2016 Marketo, Inc. 6 | # 7 | # This software may be modified and distributed under the terms 8 | # of the MIT license. See the LICENSE file for details. 9 | # 10 | require 'rest-client' 11 | require 'json' 12 | 13 | host = "CHANGE ME" 14 | client_id = "CHANGE ME" 15 | client_secret = "CHANGE ME" 16 | 17 | def get_token(host, client_id, client_secret) 18 | url = "#{host}/identity/oauth/token?grant_type=client_credentials&client_id=#{client_id}&client_secret=#{client_secret}" 19 | response = RestClient.get url 20 | json = JSON.parse(response) 21 | return json["access_token"] 22 | end 23 | 24 | id = 10000 # id of template to delete 25 | params = { 26 | :access_token => get_token(host, client_id, client_secret) 27 | } 28 | 29 | response = RestClient.post "#{host}/rest/asset/v1/emailTemplate/#{id}/delete.json", params 30 | 31 | puts response -------------------------------------------------------------------------------- /ruby/Asset/EmailTemplates/DiscartEmailTemplateDraft.rb: -------------------------------------------------------------------------------- 1 | # 2 | # DiscartEmailTemplateDraft.rb 3 | # 4 | # Marketo REST API Sample Code 5 | # Copyright (C) 2016 Marketo, Inc. 6 | # 7 | # This software may be modified and distributed under the terms 8 | # of the MIT license. See the LICENSE file for details. 9 | # 10 | require 'rest-client' 11 | require 'json' 12 | 13 | host = "CHANGE ME" 14 | client_id = "CHANGE ME" 15 | client_secret = "CHANGE ME" 16 | 17 | def get_token(host, client_id, client_secret) 18 | url = "#{host}/identity/oauth/token?grant_type=client_credentials&client_id=#{client_id}&client_secret=#{client_secret}" 19 | response = RestClient.get url 20 | json = JSON.parse(response) 21 | return json["access_token"] 22 | end 23 | 24 | id = 1001 #id of template 25 | params = { 26 | :access_token => get_token(host, client_id, client_secret) 27 | } 28 | 29 | response = RestClient.post "#{host}/rest/asset/v1/emailTemplate/#{id}/discardDraft.json", params 30 | 31 | puts response -------------------------------------------------------------------------------- /ruby/Asset/EmailTemplates/GetEmailTemplateByID.rb: -------------------------------------------------------------------------------- 1 | # 2 | # GetEmailTemplateByID.rb 3 | # 4 | # Marketo REST API Sample Code 5 | # Copyright (C) 2016 Marketo, Inc. 6 | # 7 | # This software may be modified and distributed under the terms 8 | # of the MIT license. See the LICENSE file for details. 9 | # 10 | require 'rest-client' 11 | require 'json' 12 | 13 | host = "CHANGE ME" 14 | client_id = "CHANGE ME" 15 | client_secret = "CHANGE ME" 16 | 17 | def get_token(host, client_id, client_secret) 18 | url = "#{host}/identity/oauth/token?grant_type=client_credentials&client_id=#{client_id}&client_secret=#{client_secret}" 19 | response = RestClient.get url 20 | json = JSON.parse(response) 21 | return json["access_token"] 22 | end 23 | 24 | access_token = get_token(host, client_id, client_secret) 25 | 26 | id = 1001 #id of template to retrieve 27 | params = { 28 | :status => "Approved" #status filter, Draft or Approved 29 | } 30 | 31 | response = RestClient.get "#{host}/rest/asset/v1/emailTemplate/#{id}.json?access_token=#{access_token}", {:params => params} 32 | 33 | puts response -------------------------------------------------------------------------------- /ruby/Asset/EmailTemplates/GetEmailTemplateByName.rb: -------------------------------------------------------------------------------- 1 | # 2 | # GetEmailTemplateByName.rb 3 | # 4 | # Marketo REST API Sample Code 5 | # Copyright (C) 2016 Marketo, Inc. 6 | # 7 | # This software may be modified and distributed under the terms 8 | # of the MIT license. See the LICENSE file for details. 9 | # 10 | require 'rest-client' 11 | require 'json' 12 | 13 | host = "CHANGE ME" 14 | client_id = "CHANGE ME" 15 | client_secret = "CHANGE ME" 16 | 17 | def get_token(host, client_id, client_secret) 18 | url = "#{host}/identity/oauth/token?grant_type=client_credentials&client_id=#{client_id}&client_secret=#{client_secret}" 19 | response = RestClient.get url 20 | json = JSON.parse(response) 21 | return json["access_token"] 22 | end 23 | 24 | 25 | params = { 26 | :access_token => get_token(host, client_id, client_secret), 27 | :name => "Template", #name of template, required 28 | :status => "approved" #status filter, Draft or Approved 29 | } 30 | 31 | RestClient.log = 'stdout' 32 | response = RestClient.get "#{host}/rest/asset/v1/emailTemplate/byName.json", {:params => params} 33 | 34 | puts response -------------------------------------------------------------------------------- /ruby/Asset/EmailTemplates/GetEmailTemplateContentByID.rb: -------------------------------------------------------------------------------- 1 | # 2 | # GetEmailTemplateContentByID.rb 3 | # 4 | # Marketo REST API Sample Code 5 | # Copyright (C) 2016 Marketo, Inc. 6 | # 7 | # This software may be modified and distributed under the terms 8 | # of the MIT license. See the LICENSE file for details. 9 | # 10 | require 'rest-client' 11 | require 'json' 12 | 13 | host = "CHANGE ME" 14 | client_id = "CHANGE ME" 15 | client_secret = "CHANGE ME" 16 | 17 | def get_token(host, client_id, client_secret) 18 | url = "#{host}/identity/oauth/token?grant_type=client_credentials&client_id=#{client_id}&client_secret=#{client_secret}" 19 | response = RestClient.get url 20 | json = JSON.parse(response) 21 | return json["access_token"] 22 | end 23 | 24 | id = 1001 #id of template, required 25 | params = { 26 | :access_token => get_token(host, client_id, client_secret), 27 | :status => "draft" #optional status filter, Draft of Approved 28 | } 29 | 30 | response = RestClient.get "#{host}/rest/asset/v1/emailTemplate/#{id}/content.json", {:params => params} 31 | 32 | puts response -------------------------------------------------------------------------------- /ruby/Asset/EmailTemplates/GetEmailTemplates.rb: -------------------------------------------------------------------------------- 1 | # 2 | # GetEmailTemplates.rb 3 | # 4 | # Marketo REST API Sample Code 5 | # Copyright (C) 2016 Marketo, Inc. 6 | # 7 | # This software may be modified and distributed under the terms 8 | # of the MIT license. See the LICENSE file for details. 9 | # 10 | require 'rest-client' 11 | require 'json' 12 | 13 | host = "CHANGE ME" 14 | client_id = "CHANGE ME" 15 | client_secret = "CHANGE ME" 16 | 17 | def get_token(host, client_id, client_secret) 18 | url = "#{host}/identity/oauth/token?grant_type=client_credentials&client_id=#{client_id}&client_secret=#{client_secret}" 19 | response = RestClient.get url 20 | json = JSON.parse(response) 21 | return json["access_token"] 22 | end 23 | 24 | params = { 25 | :access_token => get_token(host, client_id, client_secret), 26 | :offset => 20 #integer offset for paging 27 | } 28 | 29 | response = RestClient.get "#{host}/rest/asset/v1/emailTemplates.json", {:params => params} 30 | 31 | puts response -------------------------------------------------------------------------------- /ruby/Asset/EmailTemplates/UnapproveEmailTemplateDraft.rb: -------------------------------------------------------------------------------- 1 | # 2 | # UnapproveEmailTemplateDraft.rb 3 | # 4 | # Marketo REST API Sample Code 5 | # Copyright (C) 2016 Marketo, Inc. 6 | # 7 | # This software may be modified and distributed under the terms 8 | # of the MIT license. See the LICENSE file for details. 9 | # 10 | require 'rest-client' 11 | require 'json' 12 | 13 | host = "CHANGE ME" 14 | client_id = "CHANGE ME" 15 | client_secret = "CHANGE ME" 16 | 17 | def get_token(host, client_id, client_secret) 18 | url = "#{host}/identity/oauth/token?grant_type=client_credentials&client_id=#{client_id}&client_secret=#{client_secret}" 19 | response = RestClient.get url 20 | json = JSON.parse(response) 21 | return json["access_token"] 22 | end 23 | 24 | id = 1001 #id of template 25 | params = { 26 | :access_token => get_token(host, client_id, client_secret) 27 | } 28 | 29 | response = RestClient.post "#{host}/rest/asset/v1/emailTemplate/#{id}/unapprove.json", params 30 | 31 | puts response -------------------------------------------------------------------------------- /ruby/Asset/EmailTemplates/UpdateEmailTemplateContent.rb: -------------------------------------------------------------------------------- 1 | # 2 | # UpdateEmailTemplateContent.rb 3 | # 4 | # Marketo REST API Sample Code 5 | # Copyright (C) 2016 Marketo, Inc. 6 | # 7 | # This software may be modified and distributed under the terms 8 | # of the MIT license. See the LICENSE file for details. 9 | # 10 | require 'rest-client' 11 | require 'json' 12 | 13 | host = "CHANGE ME" 14 | client_id = "CHANGE ME" 15 | client_secret = "CHANGE ME" 16 | 17 | def get_token(host, client_id, client_secret) 18 | url = "#{host}/identity/oauth/token?grant_type=client_credentials&client_id=#{client_id}&client_secret=#{client_secret}" 19 | response = RestClient.get url 20 | json = JSON.parse(response) 21 | return json["access_token"] 22 | end 23 | 24 | id = 1001 #id of template to update 25 | params = { 26 | :access_token => get_token(host, client_id, client_secret), 27 | :content => File.new("testFile.html"), #html content 28 | } 29 | 30 | response = RestClient.post "#{host}/rest/asset/v1/emailTemplate/#{id}/content.json", params, {:multipart => true} 31 | 32 | puts response -------------------------------------------------------------------------------- /ruby/Asset/EmailTemplates/UpdateEmailTemplateMetadata.rb: -------------------------------------------------------------------------------- 1 | # 2 | # UpdateEmailTemplateMetadata.rb 3 | # 4 | # Marketo REST API Sample Code 5 | # Copyright (C) 2016 Marketo, Inc. 6 | # 7 | # This software may be modified and distributed under the terms 8 | # of the MIT license. See the LICENSE file for details. 9 | # 10 | require 'rest-client' 11 | require 'json' 12 | 13 | host = "CHANGE ME" 14 | client_id = "CHANGE ME" 15 | client_secret = "CHANGE ME" 16 | 17 | def get_token(host, client_id, client_secret) 18 | url = "#{host}/identity/oauth/token?grant_type=client_credentials&client_id=#{client_id}&client_secret=#{client_secret}" 19 | response = RestClient.get url 20 | json = JSON.parse(response) 21 | return json["access_token"] 22 | end 23 | 24 | 25 | 26 | id = 1001 # id of template to update 27 | params = { 28 | :access_token => get_token(host, client_id, client_secret), 29 | :description => "Description", #optional description 30 | :name => "New Name - Ruby" #optional new name 31 | } 32 | 33 | response = RestClient.post "#{host}/rest/asset/v1/emailTemplate/#{id}.json", params 34 | 35 | puts response -------------------------------------------------------------------------------- /ruby/Asset/Emails/ApproveEmailDraft.rb: -------------------------------------------------------------------------------- 1 | # 2 | # ApproveEmailDraft.rb 3 | # 4 | # Marketo REST API Sample Code 5 | # Copyright (C) 2016 Marketo, Inc. 6 | # 7 | # This software may be modified and distributed under the terms 8 | # of the MIT license. See the LICENSE file for details. 9 | # 10 | require 'rest-client' 11 | require 'json' 12 | 13 | host = "CHANGE ME" 14 | client_id = "CHANGE ME" 15 | client_secret = "CHANGE ME" 16 | 17 | def get_token(host, client_id, client_secret) 18 | url = "#{host}/identity/oauth/token?grant_type=client_credentials&client_id=#{client_id}&client_secret=#{client_secret}" 19 | response = RestClient.get url 20 | json = JSON.parse(response) 21 | return json["access_token"] 22 | end 23 | 24 | id = 1001 #id of email 25 | params = { 26 | :access_token => get_token(host, client_id, client_secret) 27 | } 28 | 29 | response = RestClient.post "#{host}/rest/asset/v1/email/#{id}/approveDraft.json", params 30 | 31 | puts response -------------------------------------------------------------------------------- /ruby/Asset/Emails/CloneEmail.rb: -------------------------------------------------------------------------------- 1 | # 2 | # CloneEmail.rb 3 | # 4 | # Marketo REST API Sample Code 5 | # Copyright (C) 2016 Marketo, Inc. 6 | # 7 | # This software may be modified and distributed under the terms 8 | # of the MIT license. See the LICENSE file for details. 9 | # 10 | require 'rest-client' 11 | require 'json' 12 | 13 | host = "CHANGE ME" 14 | client_id = "CHANGE ME" 15 | client_secret = "CHANGE ME" 16 | 17 | def get_token(host, client_id, client_secret) 18 | url = "#{host}/identity/oauth/token?grant_type=client_credentials&client_id=#{client_id}&client_secret=#{client_secret}" 19 | response = RestClient.get url 20 | json = JSON.parse(response) 21 | return json["access_token"] 22 | end 23 | 24 | id = 1001 #id of email 25 | params = { 26 | :access_token => get_token(host, client_id, client_secret), 27 | :name => "Clone Template - Ruby", #name of new template 28 | :folder => JSON.generate({:id => 15, :type => "Folder"}) #new folder for clone 29 | } 30 | 31 | response = RestClient.post "#{host}/rest/asset/v1/email/#{id}/clone.json", params 32 | 33 | puts response -------------------------------------------------------------------------------- /ruby/Asset/Emails/CreateEmail.rb: -------------------------------------------------------------------------------- 1 | # 2 | # CreateEmail.rb 3 | # 4 | # Marketo REST API Sample Code 5 | # Copyright (C) 2016 Marketo, Inc. 6 | # 7 | # This software may be modified and distributed under the terms 8 | # of the MIT license. See the LICENSE file for details. 9 | # 10 | require 'rest-client' 11 | require 'json' 12 | 13 | host = "CHANGE ME" 14 | client_id = "CHANGE ME" 15 | client_secret = "CHANGE ME" 16 | 17 | def get_token(host, client_id, client_secret) 18 | url = "#{host}/identity/oauth/token?grant_type=client_credentials&client_id=#{client_id}&client_secret=#{client_secret}" 19 | response = RestClient.get url 20 | json = JSON.parse(response) 21 | return json["access_token"] 22 | end 23 | 24 | 25 | params = { 26 | :access_token => get_token(host, client_id, client_secret), 27 | :name => "New Email - Ruby", 28 | :folder => JSON.generate({:id => 1071, :type => "Program"}), 29 | :template => 1001, 30 | :subject => "TEST- Ruby", #optional 31 | :fromName => "tester", #optional 32 | :fromEmail => "test@example.com", #optional 33 | :replyEmail => "text@example.com", #optional 34 | :operational => false #optional 35 | } 36 | 37 | response = RestClient.post "#{host}/rest/asset/v1/emails.json", params 38 | 39 | puts response -------------------------------------------------------------------------------- /ruby/Asset/Emails/DeleteEmail.rb: -------------------------------------------------------------------------------- 1 | # 2 | # DeleteEmail.rb 3 | # 4 | # Marketo REST API Sample Code 5 | # Copyright (C) 2016 Marketo, Inc. 6 | # 7 | # This software may be modified and distributed under the terms 8 | # of the MIT license. See the LICENSE file for details. 9 | # 10 | require 'rest-client' 11 | require 'json' 12 | 13 | host = "CHANGE ME" 14 | client_id = "CHANGE ME" 15 | client_secret = "CHANGE ME" 16 | 17 | def get_token(host, client_id, client_secret) 18 | url = "#{host}/identity/oauth/token?grant_type=client_credentials&client_id=#{client_id}&client_secret=#{client_secret}" 19 | response = RestClient.get url 20 | json = JSON.parse(response) 21 | return json["access_token"] 22 | end 23 | 24 | id = 10000 # id of template to delete 25 | params = { 26 | :access_token => get_token(host, client_id, client_secret) 27 | } 28 | 29 | response = RestClient.post "#{host}/rest/asset/v1/email/#{id}/delete.json", params 30 | 31 | puts response -------------------------------------------------------------------------------- /ruby/Asset/Emails/DiscardEmailDraft.rb: -------------------------------------------------------------------------------- 1 | # 2 | # DiscardEmailDraft.rb 3 | # 4 | # Marketo REST API Sample Code 5 | # Copyright (C) 2016 Marketo, Inc. 6 | # 7 | # This software may be modified and distributed under the terms 8 | # of the MIT license. See the LICENSE file for details. 9 | # 10 | require 'rest-client' 11 | require 'json' 12 | 13 | host = "CHANGE ME" 14 | client_id = "CHANGE ME" 15 | client_secret = "CHANGE ME" 16 | 17 | def get_token(host, client_id, client_secret) 18 | url = "#{host}/identity/oauth/token?grant_type=client_credentials&client_id=#{client_id}&client_secret=#{client_secret}" 19 | response = RestClient.get url 20 | json = JSON.parse(response) 21 | return json["access_token"] 22 | end 23 | 24 | id = 1001 #id of email 25 | params = { 26 | :access_token => get_token(host, client_id, client_secret) 27 | } 28 | 29 | response = RestClient.post "#{host}/rest/asset/v1/email/#{id}/discardDraft.json", params 30 | 31 | puts response -------------------------------------------------------------------------------- /ruby/Asset/Emails/GetEmailByID.rb: -------------------------------------------------------------------------------- 1 | # 2 | # GetEmailByID.rb 3 | # 4 | # Marketo REST API Sample Code 5 | # Copyright (C) 2016 Marketo, Inc. 6 | # 7 | # This software may be modified and distributed under the terms 8 | # of the MIT license. See the LICENSE file for details. 9 | # 10 | require 'rest-client' 11 | require 'json' 12 | 13 | host = "CHANGE ME" 14 | client_id = "CHANGE ME" 15 | client_secret = "CHANGE ME" 16 | 17 | def get_token(host, client_id, client_secret) 18 | url = "#{host}/identity/oauth/token?grant_type=client_credentials&client_id=#{client_id}&client_secret=#{client_secret}" 19 | response = RestClient.get url 20 | json = JSON.parse(response) 21 | return json["access_token"] 22 | end 23 | 24 | 25 | 26 | id = 1001 #id of template to retrieve 27 | params = { 28 | :access_token => get_token(host, client_id, client_secret), 29 | :status => "approved" #status filter, Draft or Approved 30 | } 31 | 32 | response = RestClient.get "#{host}/rest/asset/v1/email/#{id}.json", {:params => params} 33 | 34 | puts response -------------------------------------------------------------------------------- /ruby/Asset/Emails/GetEmailByName.rb: -------------------------------------------------------------------------------- 1 | # 2 | # GetEmailByName.rb 3 | # 4 | # Marketo REST API Sample Code 5 | # Copyright (C) 2016 Marketo, Inc. 6 | # 7 | # This software may be modified and distributed under the terms 8 | # of the MIT license. See the LICENSE file for details. 9 | # 10 | require 'rest-client' 11 | require 'json' 12 | 13 | host = "CHANGE ME" 14 | client_id = "CHANGE ME" 15 | client_secret = "CHANGE ME" 16 | 17 | def get_token(host, client_id, client_secret) 18 | url = "#{host}/identity/oauth/token?grant_type=client_credentials&client_id=#{client_id}&client_secret=#{client_secret}" 19 | response = RestClient.get url 20 | json = JSON.parse(response) 21 | return json["access_token"] 22 | end 23 | 24 | 25 | params = { 26 | :access_token => get_token(host, client_id, client_secret), 27 | :name => "email", #name of template, required 28 | :status => "approved" #status filter, Draft or Approved 29 | } 30 | 31 | response = RestClient.get "#{host}/rest/asset/v1/email/byName.json", {:params => params} 32 | 33 | puts response -------------------------------------------------------------------------------- /ruby/Asset/Emails/GetEmailContent.rb: -------------------------------------------------------------------------------- 1 | # 2 | # GetEmailContent.rb 3 | # 4 | # Marketo REST API Sample Code 5 | # Copyright (C) 2016 Marketo, Inc. 6 | # 7 | # This software may be modified and distributed under the terms 8 | # of the MIT license. See the LICENSE file for details. 9 | # 10 | require 'rest-client' 11 | require 'json' 12 | 13 | host = "CHANGE ME" 14 | client_id = "CHANGE ME" 15 | client_secret = "CHANGE ME" 16 | 17 | def get_token(host, client_id, client_secret) 18 | url = "#{host}/identity/oauth/token?grant_type=client_credentials&client_id=#{client_id}&client_secret=#{client_secret}" 19 | response = RestClient.get url 20 | json = JSON.parse(response) 21 | return json["access_token"] 22 | end 23 | 24 | id = 1211 #id of email, required 25 | params = { 26 | :access_token => get_token(host, client_id, client_secret), 27 | :status => "draft" #optional status filter, Draft of Approved 28 | } 29 | 30 | response = RestClient.get "#{host}/rest/asset/v1/email/#{id}/content.json", {:params => params} 31 | 32 | puts response -------------------------------------------------------------------------------- /ruby/Asset/Emails/GetEmailDynamicContent.rb: -------------------------------------------------------------------------------- 1 | # 2 | # GetEmailDynamicContent.rb 3 | # 4 | # Marketo REST API Sample Code 5 | # Copyright (C) 2016 Marketo, Inc. 6 | # 7 | # This software may be modified and distributed under the terms 8 | # of the MIT license. See the LICENSE file for details. 9 | # 10 | require 'rest-client' 11 | require 'json' 12 | 13 | host = "CHANGE ME" 14 | client_id = "CHANGE ME" 15 | client_secret = "CHANGE ME" 16 | 17 | def get_token(host, client_id, client_secret) 18 | url = "#{host}/identity/oauth/token?grant_type=client_credentials&client_id=#{client_id}&client_secret=#{client_secret}" 19 | response = RestClient.get url 20 | json = JSON.parse(response) 21 | return json["access_token"] 22 | end 23 | 24 | id = 1211 #id of email 25 | dynamicContentId = "RVMtZWRpdF90ZXh0XzE=" 26 | params = { 27 | :access_token => get_token(host, client_id, client_secret), 28 | } 29 | 30 | response = RestClient.get "#{host}/rest/asset/v1/email/#{id}/dynamicContent/#{dynamicContentId}.json", {:params => params} 31 | 32 | puts response -------------------------------------------------------------------------------- /ruby/Asset/Emails/GetEmails.rb: -------------------------------------------------------------------------------- 1 | # 2 | # GetEmails.rb 3 | # 4 | # Marketo REST API Sample Code 5 | # Copyright (C) 2016 Marketo, Inc. 6 | # 7 | # This software may be modified and distributed under the terms 8 | # of the MIT license. See the LICENSE file for details. 9 | # 10 | require 'rest-client' 11 | require 'json' 12 | 13 | host = "CHANGE ME" 14 | client_id = "CHANGE ME" 15 | client_secret = "CHANGE ME" 16 | 17 | def get_token(host, client_id, client_secret) 18 | url = "#{host}/identity/oauth/token?grant_type=client_credentials&client_id=#{client_id}&client_secret=#{client_secret}" 19 | response = RestClient.get url 20 | json = JSON.parse(response) 21 | return json["access_token"] 22 | end 23 | 24 | params = { 25 | :access_token => get_token(host, client_id, client_secret), 26 | :offset => 20 #integer offset for paging 27 | } 28 | 29 | response = RestClient.get "#{host}/rest/asset/v1/emails.json", {:params => params} 30 | 31 | puts response -------------------------------------------------------------------------------- /ruby/Asset/Emails/GetFileByID.rb: -------------------------------------------------------------------------------- 1 | # 2 | # GetFileByID.rb 3 | # 4 | # Marketo REST API Sample Code 5 | # Copyright (C) 2016 Marketo, Inc. 6 | # 7 | # This software may be modified and distributed under the terms 8 | # of the MIT license. See the LICENSE file for details. 9 | # 10 | require 'rest-client' 11 | require 'json' 12 | 13 | host = "CHANGE ME" 14 | client_id = "CHANGE ME" 15 | client_secret = "CHANGE ME" 16 | 17 | def get_token(host, client_id, client_secret) 18 | url = "#{host}/identity/oauth/token?grant_type=client_credentials&client_id=#{client_id}&client_secret=#{client_secret}" 19 | response = RestClient.get url 20 | json = JSON.parse(response) 21 | return json["access_token"] 22 | end 23 | 24 | id = 1001 25 | params = { 26 | :access_token => get_token(host, client_id, client_secret), 27 | } 28 | 29 | response = RestClient.get "#{host}/rest/asset/v1/file/#{id}.json", {:params => params} 30 | 31 | puts response -------------------------------------------------------------------------------- /ruby/Asset/Emails/GetFileByName.rb: -------------------------------------------------------------------------------- 1 | # 2 | # GetFileByName.rb 3 | # 4 | # Marketo REST API Sample Code 5 | # Copyright (C) 2016 Marketo, Inc. 6 | # 7 | # This software may be modified and distributed under the terms 8 | # of the MIT license. See the LICENSE file for details. 9 | # 10 | require 'rest-client' 11 | require 'json' 12 | 13 | host = "CHANGE ME" 14 | client_id = "CHANGE ME" 15 | client_secret = "CHANGE ME" 16 | 17 | def get_token(host, client_id, client_secret) 18 | url = "#{host}/identity/oauth/token?grant_type=client_credentials&client_id=#{client_id}&client_secret=#{client_secret}" 19 | response = RestClient.get url 20 | json = JSON.parse(response) 21 | return json["access_token"] 22 | end 23 | 24 | params = { 25 | :access_token => get_token(host, client_id, client_secret), 26 | :name => "Test File - Ruby" 27 | } 28 | 29 | response = RestClient.get "#{host}/rest/asset/v1/file/byName.json", {:params => params} 30 | 31 | puts response -------------------------------------------------------------------------------- /ruby/Asset/Emails/GetFiles.rb: -------------------------------------------------------------------------------- 1 | # 2 | # GetFiles.rb 3 | # 4 | # Marketo REST API Sample Code 5 | # Copyright (C) 2016 Marketo, Inc. 6 | # 7 | # This software may be modified and distributed under the terms 8 | # of the MIT license. See the LICENSE file for details. 9 | # 10 | require 'rest-client' 11 | require 'json' 12 | 13 | host = "CHANGE ME" 14 | client_id = "CHANGE ME" 15 | client_secret = "CHANGE ME" 16 | 17 | def get_token(host, client_id, client_secret) 18 | url = "#{host}/identity/oauth/token?grant_type=client_credentials&client_id=#{client_id}&client_secret=#{client_secret}" 19 | response = RestClient.get url 20 | json = JSON.parse(response) 21 | return json["access_token"] 22 | end 23 | 24 | params = { 25 | :access_token => get_token(host, client_id, client_secret), 26 | :folder => JSON.generate({:id => 18, :type => "Folder"}) 27 | } 28 | 29 | response = RestClient.get "#{host}/rest/asset/v1/files.json", {:params => params} 30 | 31 | puts response -------------------------------------------------------------------------------- /ruby/Asset/Emails/SendSampleEmail.rb: -------------------------------------------------------------------------------- 1 | # 2 | # SendSampleEmail.rb 3 | # 4 | # Marketo REST API Sample Code 5 | # Copyright (C) 2016 Marketo, Inc. 6 | # 7 | # This software may be modified and distributed under the terms 8 | # of the MIT license. See the LICENSE file for details. 9 | # 10 | require 'rest-client' 11 | require 'json' 12 | 13 | host = "CHANGE ME" 14 | client_id = "CHANGE ME" 15 | client_secret = "CHANGE ME" 16 | 17 | def get_token(host, client_id, client_secret) 18 | url = "#{host}/identity/oauth/token?grant_type=client_credentials&client_id=#{client_id}&client_secret=#{client_secret}" 19 | response = RestClient.get url 20 | json = JSON.parse(response) 21 | return json["access_token"] 22 | end 23 | 24 | id = 1211 #id of email to send 25 | params = { 26 | :access_token => get_token(host, client_id, client_secret), 27 | :emailAddress => "text@example.com", #email address to send to 28 | :textOnly => false, #option to send email as text only 29 | :leadId => 1 #id of lead to impersonate 30 | } 31 | 32 | response = RestClient.post "#{host}/rest/asset/v1/email/#{id}/sendSample.json", params 33 | 34 | puts response -------------------------------------------------------------------------------- /ruby/Asset/Emails/UnapproveEmail.rb: -------------------------------------------------------------------------------- 1 | # 2 | # UnapproveEmail.rb 3 | # 4 | # Marketo REST API Sample Code 5 | # Copyright (C) 2016 Marketo, Inc. 6 | # 7 | # This software may be modified and distributed under the terms 8 | # of the MIT license. See the LICENSE file for details. 9 | # 10 | require 'rest-client' 11 | require 'json' 12 | 13 | host = "CHANGE ME" 14 | client_id = "CHANGE ME" 15 | client_secret = "CHANGE ME" 16 | 17 | def get_token(host, client_id, client_secret) 18 | url = "#{host}/identity/oauth/token?grant_type=client_credentials&client_id=#{client_id}&client_secret=#{client_secret}" 19 | response = RestClient.get url 20 | json = JSON.parse(response) 21 | return json["access_token"] 22 | end 23 | 24 | id = 1001 #id of template 25 | params = { 26 | :access_token => get_token(host, client_id, client_secret) 27 | } 28 | 29 | response = RestClient.post "#{host}/rest/asset/v1/email/#{id}/unapprove.json", params 30 | 31 | puts response -------------------------------------------------------------------------------- /ruby/Asset/Emails/UpdateEmailContent.rb: -------------------------------------------------------------------------------- 1 | # 2 | # UpdateEmailContent.rb 3 | # 4 | # Marketo REST API Sample Code 5 | # Copyright (C) 2016 Marketo, Inc. 6 | # 7 | # This software may be modified and distributed under the terms 8 | # of the MIT license. See the LICENSE file for details. 9 | # 10 | require 'rest-client' 11 | require 'json' 12 | 13 | host = "CHANGE ME" 14 | client_id = "CHANGE ME" 15 | client_secret = "CHANGE ME" 16 | 17 | def get_token(host, client_id, client_secret) 18 | url = "#{host}/identity/oauth/token?grant_type=client_credentials&client_id=#{client_id}&client_secret=#{client_secret}" 19 | response = RestClient.get url 20 | json = JSON.parse(response) 21 | return json["access_token"] 22 | end 23 | 24 | id = 1211 #id of email, required 25 | params = { 26 | :access_token => get_token(host, client_id, client_secret), 27 | :subject => JSON.generate({:type => "Text", :value => "Updated Subject Line"}) 28 | } 29 | 30 | response = RestClient.post "#{host}/rest/asset/v1/email/#{id}/content.json", params 31 | 32 | puts response -------------------------------------------------------------------------------- /ruby/Asset/Emails/UpdateEmailContentSection.rb: -------------------------------------------------------------------------------- 1 | # 2 | # UpdateEmailContentSection.rb 3 | # 4 | # Marketo REST API Sample Code 5 | # Copyright (C) 2016 Marketo, Inc. 6 | # 7 | # This software may be modified and distributed under the terms 8 | # of the MIT license. See the LICENSE file for details. 9 | # 10 | require 'rest-client' 11 | require 'json' 12 | 13 | host = "CHANGE ME" 14 | client_id = "CHANGE ME" 15 | client_secret = "CHANGE ME" 16 | 17 | def get_token(host, client_id, client_secret) 18 | url = "#{host}/identity/oauth/token?grant_type=client_credentials&client_id=#{client_id}&client_secret=#{client_secret}" 19 | response = RestClient.get url 20 | json = JSON.parse(response) 21 | return json["access_token"] 22 | end 23 | 24 | id = 1211 25 | htmlId = "edit_text_1" 26 | params = { 27 | :access_token => get_token(host, client_id, client_secret), 28 | :type => "DynamicContent", 29 | :value => JSON.generate({:type => "DynamicContent", :segmentation => 1007, :default => "