Advertisement
Guest User

Untitled

a guest
Jul 20th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. add_action( 'gform_after_submission_1', 'post_contact_info', 10, 2 );
  2. function post_contact_info( $entry, $form ) {
  3. $user = 'xxxxx';
  4. $pass = 'uuuuu';
  5. $url = 'https://API.EposnowHQ.com/API/V2/Customer/';
  6. $headers = array(
  7. 'Content-Type' => 'application/json',
  8. 'Authorization' => 'Basic '. base64_encode("$user:$pass")
  9. );
  10. $contact_info = array(
  11. 'Forename' => $entry['53'],
  12. 'Surname' => $entry['55'],
  13. 'ContactNumber' => $entry['5'],
  14. 'EmailAddress' => $entry['4']
  15. );
  16. $body = json_encode( $contact_info );
  17. $args = array( 'headers' => $headers, 'body' => $body );
  18. $response = wp_remote_post( esc_url_raw( $url ), $args );
  19. $response_code = wp_remote_retrieve_response_code( $response );
  20. $response_body = wp_remote_retrieve_body( $response );
  21. $result = json_decode( $response_body );
  22.  
  23. $customer_id = $result['CustomerID'];
  24.  
  25. $address_info = array(
  26. 'CustomerID' => $customer_id,
  27. 'AddressLine1' => $entry['35'],
  28. 'Town' => $entry['36'],
  29. 'State' => $entry['38'],
  30. 'PostCode' => $entry['39']
  31. );
  32. $url2 = 'https://API.EposnowHQ.com/API/V2/CustomerAddress/';
  33. $body2 = json_encode( $address_info );
  34. $args2 = array( 'headers' => $headers, 'body' => $body2 );
  35. $response2 = wp_remote_post( esc_url_raw( $url2 ), $args2 );
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement