<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Creating a php webhook that submits form data into HubSpot CRM in APIs &amp; Integrations</title>
    <link>https://community.hubspot.com/t5/APIs-Integrations/Creating-a-php-webhook-that-submits-form-data-into-HubSpot-CRM/m-p/904431#M70264</link>
    <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/323417"&gt;@geohajj&lt;/a&gt;&amp;nbsp;- interesting project and I'm sure that such and approach would give you a lot of fexibility in form design not easily accessible in HubSpot native forms.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How does the form data get from your client side environment to the server environment necessary to execute the HubSpot API call? Remember that&amp;nbsp;web client side API calls are not permitted due to potential exposure of token credentials amongst other things -- Only HubDB calls are exempt from this last time I looked.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This may be a facet of how you have written up the problem in this post, but the header for the API call will for sure need to includeth extra data of the private app token as documented - could the issue be as simple as that?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope that I don't have the wrong end of the stick here and that this is helpful.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Steve&lt;/P&gt;</description>
    <pubDate>Thu, 11 Jan 2024 23:39:18 GMT</pubDate>
    <dc:creator>SteveHTM</dc:creator>
    <dc:date>2024-01-11T23:39:18Z</dc:date>
    <item>
      <title>Creating a php webhook that submits form data into HubSpot CRM</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Creating-a-php-webhook-that-submits-form-data-into-HubSpot-CRM/m-p/904322#M70256</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I am creating a php webhook to collect the data from an HTML form and submit them into HubSpot CRM.&lt;/P&gt;&lt;P&gt;I have already created a private app for that.&lt;/P&gt;&lt;P&gt;Can anyone tell me what I am missing:&lt;/P&gt;&lt;P&gt;&amp;lt;?php&lt;BR /&gt;if ($_SERVER['REQUEST_METHOD'] === 'POST') {&lt;BR /&gt;// Replace with your HubSpot Private App credentials&lt;BR /&gt;$clientId = 'here_I_added_the_PrivateApp_AccessToken';&lt;BR /&gt;$clientSecret = 'here_I_added_the_PrivateApp_ClientSecret';&lt;BR /&gt;$hubspotApiBaseUrl = '&lt;A href="https://api.hubapi.com" target="_blank" rel="noopener"&gt;https://api.hubapi.com&lt;/A&gt;';&lt;/P&gt;&lt;P&gt;// form data&lt;BR /&gt;$formData = $_POST;&lt;/P&gt;&lt;P&gt;// HubSpot CRM API endpoint for creating a contact&lt;BR /&gt;$endpoint = "/crm/v3/objects/contacts";&lt;/P&gt;&lt;P&gt;// HubSpot CRM API URL&lt;BR /&gt;$url = $hubspotApiBaseUrl . $endpoint;&lt;/P&gt;&lt;P&gt;// HubSpot CRM API request headers&lt;BR /&gt;$headers = [&lt;BR /&gt;'Content-Type: application/json',&lt;BR /&gt;];&lt;/P&gt;&lt;P&gt;// HubSpot CRM API request data&lt;BR /&gt;$data = [&lt;BR /&gt;'properties' =&amp;gt; [&lt;/P&gt;&lt;P&gt;['property' =&amp;gt; 'firstname','value' =&amp;gt; $formData['Full-Name'],],&lt;BR /&gt;['property' =&amp;gt; 'company','value' =&amp;gt; $formData['Company-Name'],],&lt;BR /&gt;['property' =&amp;gt; 'email','value' =&amp;gt; $formData['email'],]&lt;/P&gt;&lt;P&gt;]&lt;BR /&gt;];&lt;/P&gt;&lt;P&gt;// Initialize cURL session&lt;BR /&gt;$ch = curl_init($url);&lt;/P&gt;&lt;P&gt;// Set cURL options&lt;BR /&gt;curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);&lt;BR /&gt;curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');&lt;BR /&gt;curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));&lt;BR /&gt;curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);&lt;/P&gt;&lt;P&gt;// Execute cURL session&lt;BR /&gt;$response = curl_exec($ch);&lt;/P&gt;&lt;P&gt;// Check for errors&lt;BR /&gt;if (curl_errno($ch)) {&lt;BR /&gt;echo 'Curl error: ' . curl_error($ch);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// Close cURL session&lt;BR /&gt;curl_close($ch);&lt;/P&gt;&lt;P&gt;// Log response (for debugging)&lt;BR /&gt;file_put_contents('hubspot_response.log', $response . PHP_EOL, FILE_APPEND | LOCK_EX);&lt;BR /&gt;} else {&lt;BR /&gt;http_response_code(405); // Method Not Allowed&lt;BR /&gt;echo 'Method Not Allowed';&lt;BR /&gt;}&lt;BR /&gt;?&amp;gt;&lt;/P&gt;&lt;P&gt;========END PHP Code=========================&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And I am getting this error in the hubspot_response.log file:&lt;BR /&gt;{"status":"error","message":"Authentication credentials not found. This API supports OAuth 2.0 authentication and you can find more details at &lt;A href="https://developers.hubspot.com/docs/methods/auth/oauth-overview" target="_blank" rel="noopener"&gt;https://developers.hubspot.com/docs/methods/auth/oauth-overview&lt;/A&gt;","correlationId":"2003fc7f-1610-4fe6-b233-a0035fd19001","category":"INVALID_AUTHENTICATION"}&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2024 20:24:15 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Creating-a-php-webhook-that-submits-form-data-into-HubSpot-CRM/m-p/904322#M70256</guid>
      <dc:creator>geohajj</dc:creator>
      <dc:date>2024-01-11T20:24:15Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a php webhook that submits form data into HubSpot CRM</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Creating-a-php-webhook-that-submits-form-data-into-HubSpot-CRM/m-p/904431#M70264</link>
      <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/323417"&gt;@geohajj&lt;/a&gt;&amp;nbsp;- interesting project and I'm sure that such and approach would give you a lot of fexibility in form design not easily accessible in HubSpot native forms.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How does the form data get from your client side environment to the server environment necessary to execute the HubSpot API call? Remember that&amp;nbsp;web client side API calls are not permitted due to potential exposure of token credentials amongst other things -- Only HubDB calls are exempt from this last time I looked.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This may be a facet of how you have written up the problem in this post, but the header for the API call will for sure need to includeth extra data of the private app token as documented - could the issue be as simple as that?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope that I don't have the wrong end of the stick here and that this is helpful.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Steve&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2024 23:39:18 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Creating-a-php-webhook-that-submits-form-data-into-HubSpot-CRM/m-p/904431#M70264</guid>
      <dc:creator>SteveHTM</dc:creator>
      <dc:date>2024-01-11T23:39:18Z</dc:date>
    </item>
  </channel>
</rss>

