通过ColdFusion在Google API中创建日历时遇到问题

通过ColdFusion在Google API中创建日历时遇到问题,api,coldfusion,google-calendar-api,Api,Coldfusion,Google Calendar Api,我正在尝试使用GoogleAPI创建caledar,它只返回我帐户中的日历列表,就像我发送GET请求一样。这是我的密码: <cfxml variable="locals.xml"> <cfoutput> <entry xmlns="http://www.w3.org/2005/Atom" xmlns:gd="http://schemas.google.com/g/2005" xmlns:gCal="ht

我正在尝试使用GoogleAPI创建caledar,它只返回我帐户中的日历列表,就像我发送GET请求一样。这是我的密码:

        <cfxml variable="locals.xml">
            <cfoutput>
            <entry xmlns="http://www.w3.org/2005/Atom" xmlns:gd="http://schemas.google.com/g/2005" xmlns:gCal="http://schemas.google.com/gCal/2005">
                <title type="text">#arguments.argTitle#</title>
                <summary type="text">#arguments.argSummary#</summary>
                <cfif len(arguments.argTimezone)><gCal:timezone value="#arguments.argTimezone#"></gCal:timezone></cfif>
                <gCal:hidden value="false"></gCal:hidden>
                <gCal:accesslevel value="owner" />
                <gCal:color value="#arguments.argColor#"></gCal:color>
                <gd:where rel='' label='' valueString='Oakland'></gd:where>
            </entry>
            </cfoutput>
        </cfxml>

        <cfhttp url="#variables.baseURL#/default/owncalendars/full" method="post" redirect="false" multiparttype="related" charset="utf-8">
            <cfhttpparam type="header" name="Authorization" value="GoogleLogin auth=#getAuth(variables.serviceName)#">
            <cfhttpparam type="header" name="Content-Type" value="application/atom+xml">
            <cfhttpparam type="header" name="GData-Version" value="2">
            <cfhttpparam type="body" value="#trim(locals.xml)#">
        </cfhttp>

#arguments.argTitle#
#arguments.argSummary#

任何帮助都将不胜感激。

CFXML将创建一个ColdFusion XML对象。这是一个内部CFML构造,对接收API没有任何意义。我希望您需要将其转换为文本

尝试使用ToString()包装locals.xml。像这样:

<cfhttp url="#variables.baseURL#/default/owncalendars/full" method="post"
    redirect="false" multiparttype="related" charset="utf-8">
    <cfhttpparam type="header" name="Authorization" value="GoogleLogin 
        auth=#getAuth(variables.serviceName)#">
    <cfhttpparam type="header" name="Content-Type"
        value="application/atom+xml">
    <cfhttpparam type="header" name="GData-Version" value="2">
    <cfhttpparam type="body" value="#trim(toString(locals.xml))#">
</cfhttp>

首先,我会将要发送的XML输出到文本框中,并将其显示在屏幕上,以验证其格式是否正确:

<textarea rows="30" cols="120">
  <cfoutput>#trim(toString(locals.xml))#</cfoutput>
</textarea>

#trim(toString(locals.xml))#

您可能会考虑的另一种方法是将XML构建为字符串,而不是将后来转换为字符串的本机CordDFixXML对象(注意,我使用CFSAVECCONTUNT而不是CFXML)


#arguments.argTitle#
#arguments.argSummary#

我做了更改,但我仍然得到了200,而且没有创建新日历。啊。那好吧。恐怕我对谷歌api了解不够,无法提供更具建设性的内容。雷·卡姆登(Ray Camden)有某种谷歌api——你看过他的博客了吗?是的。。。我正在使用他的api,我正在扩展它以使用日历(他的代码做文档和分析)。我编写了一个函数,可以成功地在帐户中获取日历。然而,我正在遵循我在所有网站上看到的例子,加上谷歌api页面,我似乎无法让它创建日历,好像它忽略了我发送的标题信息。我想出来了。。。我没有传递GSSessionID,重定向正在丢失标题信息。。。不管怎样,谢谢你的帮助。我把它改成了cfsavecontent,但还是不起作用。事实上,我把它改成了谷歌API页面上的例子,但这也不起作用。你能更具体一点吗?“它不起作用”帮不了什么忙。
<cfsavecontent variable="locals.xml">
    <cfoutput>
    <entry xmlns="http://www.w3.org/2005/Atom" xmlns:gd="http://schemas.google.com/g/2005" xmlns:gCal="http://schemas.google.com/gCal/2005">
        <title type="text">#arguments.argTitle#</title>
        <summary type="text">#arguments.argSummary#</summary>
        <cfif len(arguments.argTimezone)><gCal:timezone value="#arguments.argTimezone#"></gCal:timezone></cfif>
        <gCal:hidden value="false"></gCal:hidden>
        <gCal:accesslevel value="owner" />
        <gCal:color value="#arguments.argColor#"></gCal:color>
        <gd:where rel='' label='' valueString='Oakland'></gd:where>
    </entry>
    </cfoutput>
</cfsavecontent>