Skip links

How To Integrate Salesforce Marketing Cloud With PHP Using REST API?

Lets Understand first, What is REST API?

REST API allows you to interact with Salesforce Marketing Cloud from outside the Salesforce. That means that you can create / update / delete records in Salesforce Marketing Cloud from outside the salesforce.

API is used when you want to integrate salesforce with your applications, and your application can be in any language like PHP, Java, .Net etc.

For example, Suppose you have a program containing the contact form.And you want to store data to the salesforce platform whenever form is submitted. For that REST API is useful.

Lets Proceed Further with Practical Part :

Pre-requisites – In

  • First you need a Salesforce account. you can create it from Here (
  • You will need to create a application for authorization in salesforce. To create Application, click on Setup (right uper menu) > Create (left side – built menu) > Apps then create a new Connected App.
  • Set the callback URL to: https:///salesforce/oauth_callback (SSL is mandatory)
  • Select at least “Perform requests on your behalf at any time” for OAuth Scope. This will use for other scopes in your application.
  • Need Data Extension In Salesforce Account.
Related Blog: Five Key Benefits of API Management For Your Business.
Learn More

How to Create Data Extension in Salesforce.

Step: 1

Login into your salesforce Account and hover on email studio in navigation bar and click on Email.

Step: 2

Hover over Subscribers  and Click Data Extensions

Step: 3

Click the Create button. You have three options:

Click Standard Data Extension and click ok

Step: 4
  • Complete the information in the Properties section:
  • Creation Method – The method used to create the data extension. Select Create from New.
  • Name – The name of the data extension. Use this name to identify the data extension.
  • External Key – A unique value that identifies the data extension. Use this value to identify the data extension with an API call.
  • Description – A description of the data extension, optional.
  • Location – To store the data extension in a different folder location, optional, select Change Location
  • Click Next
Step: 5

Retention Settings is optional.

Step: 6

In fields section you can define all fields you want in your data extension.

Now Data Extension is ready to receive data when we push there.

Lets do the code for submiting data to the salesforce.

To create plugin we need to create folder and file in :  project->wp-content->plugins->folder_name->file_name.php

For example : Project->wp-content->plugins->marketing->marketing.php


Code Snippet:

Put this code in your php file and get all the values in variables using $_POST.

Make sure to map field names with the salesforce fields to submit data successfully.

Your Form is now ready with the Salesforce integration.

This website uses cookies to improve your web experience.