Return to Snippet

Revision: 30691
at August 19, 2010 14:48 by Xhitman


Initial Code
Visualforce Page
<apex:page setup="true" controller="MyController" showHeader="false">
<apex:form >
 <apex:outputpanel id="counter">
 <apex:outputText value="Click Here To Generate Session Id and Server URL" /> 
 <apex:actionSupport event="onclick" action="{!doLogin}" rerender="refreshId" status="counterStatus">
 <apex:param name="sessionId" assignTo="{!apiSessionId}" value="{!$Api.Session_ID}" />
 <apex:param name="serverURL" assignTo="{!apiServerURL}" value="{!$Api.Partner_Server_URL_140}" /> 
 </apex:actionSupport> 
 </apex:outputpanel><br></br> 
 <apex:outputPanel id="refreshId">
 <apex:outputText value="API Session Id: {!apiSessionId}"/><br></br>
 <apex:outputText value="API Server URL: {!apiServerURL}"/><br></br>
 </apex:outputPanel>
</apex:form> 
</apex:page>


Controller Apex Class
public class MyController {

 public String apiSessionId {get;set;} 
 public String apiServerURL {get;set;} 
 
 public PageReference doLogin(){ 
  System.debug('apiSessionId: ' + apiSessionId); 
  System.debug('apiServerURL: ' + apiServerURL); 
  return null; 
 }

}

Initial URL
http://blog.sforce.com/sforce/2009/01/accessing-session-id-and-api-server-url-parameters-with-visualforce.html

Initial Description
Credits to Andrew Albert

Initial Title
Accessing Session Id and API Server URL parameters with Visualforce

Initial Tags

                                

Initial Language
Other