我正在尝试从flex登录到salesforce,但我得到security error accessing url
。
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:salesforce="http://www.salesforce.com/"
layout="absolute" width="500" height="300"
backgroundGradientAlphas="[1.0, 1.0]"
backgroundGradientColors="[#FFFFFF, #FFFFFF]" applicationComplete="init()">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.collections.ArrayCollection;
import com.salesforce.results.QueryResult;
import com.salesforce.results.LoginResult;
import com.salesforce.AsyncResponder;
import com.salesforce.objects.LoginRequest;
import com.salesforce.AsyncResponder;
import com.salesforce.events.ApexFaultEvent;
import com.salesforce.objects.LoginRequest;
import com.salesforce.objects.SObject;
import com.salesforce.results.Fault;
import com.salesforce.results.LoginResult;
import com.salesforce.results.QueryResult;
import com.salesforce.results.UpsertResult;
[Bindable]
private var opps:ArrayCollection;
private function init():void
{
var lr:LoginRequest = new LoginRequest();
force.protocol = "https";
force.serverUrl = "https://ap1.salesforce.com/services/Soap/c/15.0";
lr.username = "my login username";
lr.password = "pwdandsectoken"; // You may need the security token if so please append the security token eg: passwordsecurityToken
lr.callback = new AsyncResponder(loginHandler,faultHandler);
force.login(lr);
}
private function loginHandler(result:LoginResult):void
{
Alert.show('login');
force.query("SELECT Name FROM Account",
new AsyncResponder(queryHandler, faultHandler));
}
private function queryHandler(result:QueryResult):void
{
opps = result.records;
}
private function faultHandler(result:com.salesforce.results.Fault):void
{
Alert.show("Login failed.\nError Code: " + result.faultcode + ':' + result.faultstring + ':' +result.detail);
}
]]>
</mx:Script>
<salesforce:Connection id="force"/>
<mx:BarChart id="chart" dataProvider="{opps}" top="10" bottom="10" left="10" right="10">
<mx:verticalAxis>
<mx:CategoryAxis dataProvider="{opps}" categoryField="Name"/>
</mx:verticalAxis>
<mx:series>
</mx:series>
</mx:BarChart>
</mx:Application>
这是我用来构建swf文件的代码。我无法登录。我需要在Salesforce站点上嵌入此表单。
答案 0 :(得分:0)
您的Salesforce服务器实例是什么?您可以通过Web浏览器登录Salesforce进行检查,它将在salesforce.com之前的URL中显示。例如:
<强> CS7 强> .salesforce.com
然后它可能会在您的服务器URL中使用。你的情况下是 ap1 吗?