用于发布到 Google Voice“API”的 CFHTTP 内容长度标头

发布于 2024-09-24 12:04:43 字数 1322 浏览 0 评论 0原文

问候。

我正在尝试使用他们现有的 API 通过谷歌语音发送一条快速短信。我认为 api 是大中央时代留下的东西。他们没有太多文档。这是我获取文档的位置:http://posttopic.com/topic/google -voice-add-on-development

我可以使用 cfhttp 进行身份验证并获得正确的响应。然后我可以从谷歌语音命令获取请求所需的“_rnr_se”值。

当我发送号码、消息和所需值(授权和_rnr_se)时,我收到来自谷歌的“内容长度”是必需的消息。但由于这是一个具有不同表单字段的动态帖子,而不是一个文件,因此我不确定要发布什么内容作为内容长度。

如果我只是为内容长度输入一些任意值,例如“1000”,则请求只会放在那里,而我永远不会得到响应。如果我输入“0”或“500”之类的内容,它会返回 500 - “内部服务器错误”。

关于如何在发布之前获得正确的内容长度值有什么想法吗?

<cffunction name="submitSMS">

    <cfhttp url="https://www.google.com/voice/sms/send/" method="post">
        <cfhttpparam type="header" name="Content-Length" value="???">
        <cfhttpparam type="header" name="Authorization" value="GoogleLogin auth=#SESSION.GoogleAuth#">
        <cfhttpparam name="id" value="" type="formfield">
        <cfhttpparam name="phoneNumber" value="+1#params.number#" type="formfield">
        <cfhttpparam name="text" value="#params.smsMessage#" type="formfield">
        <cfhttpparam name="_rnr_se" value="#SESSION.rnr#" type="formfield">
    </cfhttp>

    <cfdump var="#cfhttp.FileContent#"><cfabort>
</cffunction>

Greetings.

I'm trying to send a quick sms through google voice using their existing API. I think the api is what's left from the Grand Central days. They don't have much documentation. Here's where I got my documentation: http://posttopic.com/topic/google-voice-add-on-development

I can authenticate using cfhttp and get the correct response. Then I can get the "_rnr_se" value that is required for request from a google voice command.

When I send over the number, message, and required values (Authorization and _rnr_se), I get a "content-length" is required message from google. But since this is a dynamic post with different form fields, not a file, I'm not sure what to post as the content-length.

If I just put some arbitrary value like "1000" for the content-length, the request just sits there and I never get a response. If I put something like "0" or "500" it comes back with a 500 - "Internal Server Error".

Any ideas on how to get the correct value for content-length before I post?

<cffunction name="submitSMS">

    <cfhttp url="https://www.google.com/voice/sms/send/" method="post">
        <cfhttpparam type="header" name="Content-Length" value="???">
        <cfhttpparam type="header" name="Authorization" value="GoogleLogin auth=#SESSION.GoogleAuth#">
        <cfhttpparam name="id" value="" type="formfield">
        <cfhttpparam name="phoneNumber" value="+1#params.number#" type="formfield">
        <cfhttpparam name="text" value="#params.smsMessage#" type="formfield">
        <cfhttpparam name="_rnr_se" value="#SESSION.rnr#" type="formfield">
    </cfhttp>

    <cfdump var="#cfhttp.FileContent#"><cfabort>
</cffunction>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情丝乱 2024-10-01 12:04:43

更好的方法是在这里使用 google voice java 类:

http://google-voice -java.googlecode.com

The better way to do this is to just use the google voice java class here:

http://google-voice-java.googlecode.com

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文