We're trying to have a Gravity form subit into HubSpot using the HubSpot form/lead API.
We read this forum topic but there's no reply: http://www.gravityhelp.com/forums/topic/gform_after_submission-hook-with-3rd-api-hubspot
Here is the code that we are unsuccessfully trying to execute in our functions.php. Any suggestions?
<?php
/* Load the Theme class. */
require_once (TEMPLATEPATH . '/framework/theme.php');
$theme = new Theme();
$theme->init(array(
	'theme_name' => 'Striking',
	'theme_slug' => 'striking'
));
add_action("gform_after_submission", "after_submission", 10, 2);
function after_submission($entry, $form) {
  //START HubSpot Lead Submission
  $strPost = "";
  //create string with form POST data
  $strPost = "FirstName=" . urlencode($_POST['first_name'])
  . "&LastName=" . urlencode($_POST['last_name'])
  . "&Email=" . urlencode($_POST['email'])
  . "&TwitterHandle=" . urlencode($_POST['twitter_handle’])
  . "&Phone=" . urlencode($_POST['phone_number'])
  . "&Fax=" . urlencode($_POST['fax_number'])
  . "&Website=" . urlencode($_POST['website'])
  . "&Company=" . urlencode($_POST['company'])
  . "&JobTitle=" . urlencode($_POST['job_title'])
  . "&Address=" . urlencode($_POST['address'])
  . "&City=" . urlencode($_POST['city'])
  . "&State=" . urlencode($_POST['state'])
  . "&ZipCode=" . urlencode($_POST['zip_code'])
  . "&Country=" . urlencode($_POST['country'])
  . "&Message=" . urlencode($_POST['message'])
  . "&NumberEmployees=" . urlencode($_POST['num_employees'])
  . "&AnnualRevenue=" . urlencode($_POST['annual_revenue'])
  . "&CloseDate=" . urlencode($_POST['close_date'])
  . "&IPAddress=" . urlencode($_SERVER['REMOTE_ADDR'])
  . "&UserToken=" . urlencode($_COOKIE['hubspotutk']);
  //set POST URL
  $url = "http://insightsquared.app11.hubspot.com/?app=leaddirector&FormName=Contact+Us";
  //intialize cURL and send POST data
  $ch = @curl_init();
  @curl_setopt($ch, CURLOPT_POST, true);
  @curl_setopt($ch, CURLOPT_POSTFIELDS, $strPost);
  @curl_setopt($ch, CURLOPT_URL, $url);
  @curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  @curl_exec($ch);
  @curl_close($ch);
  //END HubSpot Lead Submission
}
?>