Last active
October 23, 2024 12:05
-
-
Save BhargavBhandari90/6bbbc34a6f6bac568bc75a608d635548 to your computer and use it in GitHub Desktop.
get Salesforce contact in WordPress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$access_token = 'Your access token'; | |
if (!$access_token) { | |
return 'Error: Unable to retrieve access token'; | |
} | |
$api_url = 'https://yourdomain.my.salesforce.com/services/data/v55.0/sobjects/Contact/' . $contact_id; | |
$response = wp_remote_get($api_url, array( | |
'headers' => array( | |
'Authorization' => 'Bearer ' . $access_token, | |
'Content-Type' => 'application/json', | |
), | |
)); | |
if (is_wp_error($response)) { | |
return 'Error: ' . $response->get_error_message(); | |
} | |
$data = json_decode(wp_remote_retrieve_body($response), true); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment