Advertisement
verygoodplugins

Untitled

Jun 25th, 2018
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.46 KB | None | 0 0
  1. function add_object( $data, $object_type ) {
  2.  
  3.     $params = wp_fusion()->crm->get_params();
  4.     $params['headers']['Content-Type'] = 'application/json';
  5.  
  6.     $params['body'] = json_encode( $data );
  7.     $response = wp_remote_post( wp_fusion()->crm->instance_url . '/services/data/v20.0/sobjects/' . $object_type . '/', $params );
  8.  
  9.     if( is_wp_error( $response ) ) {
  10.         return $response;
  11.     }
  12.  
  13.     $body = json_decode(wp_remote_retrieve_body($response));
  14.  
  15.     return $body->id;
  16.  
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement