Skip to content

Instantly share code, notes, and snippets.

@BhargavBhandari90
Last active October 23, 2024 12:05
Show Gist options
  • Save BhargavBhandari90/6bbbc34a6f6bac568bc75a608d635548 to your computer and use it in GitHub Desktop.
Save BhargavBhandari90/6bbbc34a6f6bac568bc75a608d635548 to your computer and use it in GitHub Desktop.
get Salesforce contact in WordPress
<?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