Forked from richardvanhook/SimpleProxyClient.page
Created
September 28, 2013 09:41
-
-
Save piyushrajput/6740401 to your computer and use it in GitHub Desktop.
This file contains 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
<apex:page docType="html-5.0" sidebar="false" showHeader="false" | |
standardStylesheets="false" cache="true"> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"/> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script> | |
<script type="text/javascript"> | |
var SESSION_ID = '{!$Api.Session_ID}'; | |
var SERVER_URL = '{! 'https://'+ | |
RIGHT(SUBSTITUTE( | |
LEFT($Api.Partner_Server_URL_210, FIND( '/services', $Api.Partner_Server_URL_260)) | |
,'visual.force','salesforce' | |
),FIND('c.', | |
SUBSTITUTE( | |
LEFT($Api.Partner_Server_URL_210, FIND( '/services', $Api.Partner_Server_URL_260)) | |
,'visual.force','salesforce'))-2)}'; | |
var PATH = 'services/data/v26.0/chatter/users/me'; | |
$(function(){ | |
$.ajax({ | |
cache: false, | |
url: '/services/proxy', | |
beforeSend: function(xhr) { | |
xhr.setRequestHeader('SalesforceProxy-Endpoint', SERVER_URL + PATH); | |
xhr.setRequestHeader('Authorization', 'OAuth ' + SESSION_ID); | |
}, | |
success: function(data,status,xhr){ | |
$('body').html('Done! You are <b>' + data.name | |
+ '</b>, and I, this humble page, retrieved your name from the REST API.'); | |
}, | |
error: function(xhr,status,errorThrown){ | |
$('body').html('Oh no! Got this error: <br/><b style="color:red">' | |
+ xhr.status + ' ' + errorThrown + ' ' + xhr.responseText + '</b>'); | |
} | |
}); | |
}); | |
</script> | |
</head> | |
<body>Loading...</body> | |
</html> | |
</apex:page> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment