APIs & Integrations

ASmith3
Participant

Contact create API -> CURLOPT_POSTFIELDS populated with variables

SOLVE

Hi,

 

I am attempting to pass information from my LMS (hosted on WordPress) through to HubSpot. Currently I have it set up such that it can create a new contact by using fixed values (so this function runs after the form submits):

 

CURLOPT_POSTFIELDS => "{\"properties\":{\"company\":\"Alex\",\"email\":\"alex@alex.net\",\"firstname\":\"Alex\",\"lastname\":\"Alex\",\"phone\":\"(888) 888 888\",\"website\":\"alex.net\"}}",

 

However, I'd like to be able to submit  variables - particularly, the input values from the payment submission.

 

Attempted this as so:

 

$email1 = $_POST['email_address'];

 

CURLOPT_POSTFIELDS => "{\"properties\":{\"company\":\"Alex\",\"email\":\$email1,\"firstname\":\"Alex\",\"lastname\":\"Alex\",\"phone\":\"(888) 888 888\",\"website\":\"alex.net\"}}",

 

 

But no luck. Can anyone advise on how I might solve this?

 

Thanks!

Alex

1 Accepted solution
tjoyce
Solution
Recognized Expert | Gold Partner
Recognized Expert | Gold Partner

Contact create API -> CURLOPT_POSTFIELDS populated with variables

SOLVE

@ASmith3 - Have you tried 

CURLOPT_POSTFIELDS => json_encode([
  'properties' => [
    'company' => 'Alex',
    'email' => $_POST['email_address'],
    'firstname' => 'Alex'
  ]
]);

View solution in original post

3 Replies 3
ASmith3
Participant

Contact create API -> CURLOPT_POSTFIELDS populated with variables

SOLVE

Hi @dennisedson @tjoyce,

 

That has done it! Thank you so much, I would not like to hazard a guess at how much time that has saved me.

 

Thank you and have a great rest of the week!

 

Many thanks,

Alex

tjoyce
Solution
Recognized Expert | Gold Partner
Recognized Expert | Gold Partner

Contact create API -> CURLOPT_POSTFIELDS populated with variables

SOLVE

@ASmith3 - Have you tried 

CURLOPT_POSTFIELDS => json_encode([
  'properties' => [
    'company' => 'Alex',
    'email' => $_POST['email_address'],
    'firstname' => 'Alex'
  ]
]);
dennisedson
HubSpot Product Team
HubSpot Product Team

Contact create API -> CURLOPT_POSTFIELDS populated with variables

SOLVE

Hi @ASmith3 

Are you still working with this one?

Wanted to throw @tjoyce at it this to help out 😀


HubSpot’s AI-powered customer agent resolves up to 50% of customer queries instantly, with some customers reaching up to 90% resolution rates.
Learn More.