函数启动时出现意外的T_VARIABLE错误

时间:2018-10-22 17:21:18

标签: php wordpress salesforce contact-form-7

我正在尝试在Wordpress中为cf7表单添加Salesforce集成。现在我有这个:

add_action( 'wpcf7_before_send_mail', 'my_conversion' );
function my_conversion( $cf7 ) {
  $cf7_email = $cf7->posted_data["email"];
  $cf7_first_name  = $cf7->posted_data["firstname"];
  $cf7_last_name  = $cf7->posted_data["lastname"];
  $cf7_phone = $cf7->posted_data["cellphone"];
  $cf7_company_name = $cf7->posted_data["companyname"];
  $cf7_notes = $cf7->posted_data["notes"];
 
  $post_items[] = 'oid=****';
  $post_items[] = 'first_name=' . $cf7_first_name;
  $post_items[] = 'last_name=' . $cf7_last_name;
  $post_items[] = 'email=' . $cf7_email;
  $post_items[] = 'phone=' . $cf7_phone;
  $post_items[] = 'company_name=' . $cf7_company_name;
  $post_items[] = 'notes=' . $cf7_notes;
 
  if(!empty($cf7_first_name) && !empty($cf7_last_name) && !empty($cf7_email) )
  {
    $post_string = implode ('&', $post_items);
    // Create a new cURL resource
    $ch = curl_init();
  
    if (curl_error($ch) != "")
    {
      // error handling
    }
  
    $con_url = 'https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8';
    curl_setopt($ch, CURLOPT_URL, $con_url);
    // Set the method to POST
    curl_setopt($ch, CURLOPT_POST, 1);
    // Pass POST data
    curl_setopt( $ch, CURLOPT_POSTFIELDS, $post_string);
    curl_exec($ch); // Post to Salesforce
    curl_close($ch); // close cURL resource
  }
}

但是它一直在给我unexpected T_VARIABLE on line 3 ($cf7_email = $cf7->posted_data["email"];)。 我到处搜索了解决方案,但是找不到。

0 个答案:

没有答案