通过PHP的CRM Online 2015 API-securityToken问题

通过PHP的CRM Online 2015 API-securityToken问题,php,curl,dynamics-crm-2015,Php,Curl,Dynamics Crm 2015,我必须用PHP语言实现一些处理Microsoft Dynamics CRM 2015的代码,而且,由于我对Dynamics CRM和Microsoft服务完全陌生,这对我来说相当棘手,因为没有一个适合非.NET语言的优秀文档 我需要做的是创建PHP API,读取并向Dynamic CRM 2015的“联系人”和“帐户”表添加行 通过谷歌搜索,我发现auth部分的主要部分应该分为四个主要步骤(摘自Girish Raja的博客): 我成功地通过了第一点,并从DeviceAddCredential.s

我必须用PHP语言实现一些处理Microsoft Dynamics CRM 2015的代码,而且,由于我对Dynamics CRM和Microsoft服务完全陌生,这对我来说相当棘手,因为没有一个适合非.NET语言的优秀文档

我需要做的是创建PHP API,读取并向Dynamic CRM 2015的“联系人”和“帐户”表添加行

通过谷歌搜索,我发现auth部分的主要部分应该分为四个主要步骤(摘自Girish Raja的博客):

我成功地通过了第一点,并从DeviceAddCredential.srf获得了puid,但似乎没有办法支付第二点。我不断得到“输入和存储的密码不匹配”

实际上,我使用的是Ben Speakman的DynamicClient类,由于它是2011年的一个类,我猜它的登录过程可能有问题(例如,我不得不修复代码升级中的另一个问题)

下面是试图获取设备凭据的getBinaryDAToken函数。我不确定的是url正在使用。我的猜测是,也许auth服务已经从login.live.com迁移了,我应该为office 365产品调用一个类似的服务,而不是login.live.com

其他一些脚本使用login.microsoftonline.com/extSTS.srf,但看起来更旧

您能帮我完成这个身份验证过程吗? 太多了

private function getBinaryDAToken(){

        $deviceCredentialsSoapTemplate = '
        <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
            <s:Header>
                <a:Action s:mustUnderstand="1">http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue</a:Action>
                <a:MessageID>
                    urn:uuid:'.$this->messageid.'
                </a:MessageID>
                <a:ReplyTo><a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address></a:ReplyTo>
                <VsDebuggerCausalityData xmlns="http://schemas.microsoft.com/vstudio/diagnostics/servicemodelsink">uIDPoy9Ez+P/wJdOhoN2XNauvYcAAAAAK0Y6fOjvMEqbgs9ivCmFPaZlxcAnCJ1GiX+Rpi09nSYACQAA</VsDebuggerCausalityData>
                <a:To s:mustUnderstand="1">https://login.live.com/liveidSTS.srf</a:To>
                <o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
                    <u:Timestamp u:Id="_0">
                        <u:Created>'.$this->currentTime.'Z</u:Created>
                        <u:Expires>'.$this->nextDayTime.'Z</u:Expires>
                    </u:Timestamp>
                    <o:UsernameToken u:Id="devicesoftware">
                        <o:Username>'.$this->deviceUserName.'</o:Username>
                        <o:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">
                            '.$this->devicePassword.'
                        </o:Password>
                    </o:UsernameToken>
                </o:Security>
            </s:Header>
            <s:Body>
                <t:RequestSecurityToken xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust">
                    <wsp:AppliesTo xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
                        <a:EndpointReference>
                            <a:Address>http://passport.net/tb</a:Address>
                        </a:EndpointReference>
                    </wsp:AppliesTo>
                    <t:RequestType>http://schemas.xmlsoap.org/ws/2005/02/trust/Issue</t:RequestType>
                </t:RequestSecurityToken>
            </s:Body>
        </s:Envelope>';

        return $this->doCurl("/liveidSTS.srf" , "login.live.com" , "https://login.live.com/liveidSTS.srf", $deviceCredentialsSoapTemplate);



    }
私有函数getBinaryDAToken(){
$deviceCredentialsSoapTemplate='1!'

解决了第二步问题

CRM Online已从旧的身份验证方法(Windows Live)更改为需要设备凭据的身份验证方法,现在使用Office 365,这(在我看来)使事情变得更简单、速度更快

我写了一篇关于这一点的博客:-

Jason Lattimer最近还写了一个博客,它将提供一个你可以尝试和实现的库,并且可以在本地使用(我的没有)

Thanx很多,Campey这解决了我的第二步问题。
private function getBinaryDAToken(){

        $deviceCredentialsSoapTemplate = '
        <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
            <s:Header>
                <a:Action s:mustUnderstand="1">http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue</a:Action>
                <a:MessageID>
                    urn:uuid:'.$this->messageid.'
                </a:MessageID>
                <a:ReplyTo><a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address></a:ReplyTo>
                <VsDebuggerCausalityData xmlns="http://schemas.microsoft.com/vstudio/diagnostics/servicemodelsink">uIDPoy9Ez+P/wJdOhoN2XNauvYcAAAAAK0Y6fOjvMEqbgs9ivCmFPaZlxcAnCJ1GiX+Rpi09nSYACQAA</VsDebuggerCausalityData>
                <a:To s:mustUnderstand="1">https://login.live.com/liveidSTS.srf</a:To>
                <o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
                    <u:Timestamp u:Id="_0">
                        <u:Created>'.$this->currentTime.'Z</u:Created>
                        <u:Expires>'.$this->nextDayTime.'Z</u:Expires>
                    </u:Timestamp>
                    <o:UsernameToken u:Id="devicesoftware">
                        <o:Username>'.$this->deviceUserName.'</o:Username>
                        <o:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">
                            '.$this->devicePassword.'
                        </o:Password>
                    </o:UsernameToken>
                </o:Security>
            </s:Header>
            <s:Body>
                <t:RequestSecurityToken xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust">
                    <wsp:AppliesTo xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
                        <a:EndpointReference>
                            <a:Address>http://passport.net/tb</a:Address>
                        </a:EndpointReference>
                    </wsp:AppliesTo>
                    <t:RequestType>http://schemas.xmlsoap.org/ws/2005/02/trust/Issue</t:RequestType>
                </t:RequestSecurityToken>
            </s:Body>
        </s:Envelope>';

        return $this->doCurl("/liveidSTS.srf" , "login.live.com" , "https://login.live.com/liveidSTS.srf", $deviceCredentialsSoapTemplate);



    }