尝试向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请求吗?
谢谢。