嘗試向Salesforce.com發送經過驗證的GET請求時,出現錯誤(INVALID_SESSION_ID)。無法驗證Wordpress插件中的Salesforce
這裏是它的全部,它基本上只是輸出REST響應任何網頁中有[MembershipTables]簡碼的身體插件:
if (!class_exists('WP_Http')) {
include_once(ABSPATH . WPINC . '/class-http.php');
}
// This is obviously the real username
$username = '[email protected]';
// And this is obviously the real password concatonated with the security token
$password = 'xxxxxxxxxxxxxx';
function getMembershipTables() {
$api_url = 'https://na15.salesforce.com/services/apexrest/directory';
$headers = array('Authorization' => 'Basic ' . base64_encode("$username:$password"));
$args = array('headers' => $headers);
$request = new WP_Http;
$result = $request->request($api_url, $args);
$body = $result['body'];
echo "$body";
}
add_shortcode('MembershipTables', 'getMembershipTables');
我要指出,我能成功攻克這個儘管我使用的是使用舊SOAP API從Salesforce獲得的會話令牌,以保持其等效(即沒有客戶端ID /密碼)。
我做錯了WP_Http?或者我不能使用基本身份驗證來驗證salesforce.com請求嗎?
謝謝。