Advertisement
verygoodplugins

Untitled

Sep 27th, 2018
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.65 KB | None | 0 0
  1. // $params has the authorization headers in it
  2. $params = wp_fusion()->crm->get_params();
  3.  
  4. // This is the data for the new company
  5. $data = array(
  6.     'Company_Name'  => 'Cool company',
  7.     'Another_Field' => 'More data'
  8. );
  9.  
  10. $params['body'] = json_encode( array( 'data' => array( $data ) ) );
  11.  
  12. $request = wp_fusion()->crm->api_domain . '/crm/v2/Companies';
  13. $response = wp_remote_post( $request, $params );
  14.  
  15. // Check for any errors and display them if encountered
  16. if( is_wp_error( $response ) ) {
  17.     wp_die( $response->get_error_message() );
  18. }
  19.  
  20. $response = json_decode( wp_remote_retrieve_body( $response ) );
  21.  
  22. $company_id = $response->data[0]->details->id;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement