daily pastebin goal
13%
SHARE
TWEET

Untitled

a guest Jan 18th, 2019 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. add_action('gform_after_submission_1', 'after_submission', 10, 2);
  2.    
  3. function after_submission($entry, $form)
  4. {
  5.     $url = "https://www.XXXXXXX.com/wp-admin/admin-ajax.php";
  6.  
  7.  
  8. // initialise the curl request
  9. $request = curl_init($url);
  10.  
  11. $file_temp = download_url($entry[19], 5);
  12.  
  13. // send a file
  14. curl_setopt($request, CURLOPT_POST, true);
  15. curl_setopt(
  16.     $request,
  17.     CURLOPT_POSTFIELDS,
  18.     array(
  19.         'action' => 'wsdesk_api_create_ticket', // Request Type
  20.         'api_key' => 'XXXXXXXXXXXXXXXXXXXXX', //API Key.
  21.         'request_email' => $entry[2],// email
  22.         'request_title' => $entry[6.1], // address
  23.         // 'request_description' => $entry[12],
  24.         'field_ZO15' => $entry[1], // full name
  25.         'field_RJ34' => $entry[3], //phone number
  26.         'field_XH64' => $entry[10],// type of inspection
  27.         'field_YM91' => $entry[8], // Time inspection
  28.         'file[]' => $file_temp
  29.     )
  30. );
  31. print_r("file: $file_temp");
  32.  
  33. // output the response
  34.     curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
  35.     echo curl_exec($request);
  36.  
  37. // close the session
  38.     curl_close($request);
  39. $response = json_decode($response['body'], true);
  40. die(print_r($response, true));
  41. if ($response['status'] == 'success') {
  42.     die('success');
  43. } //code if success
  44. else {
  45.     die('failed');
  46. } //code if fails
  47. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top