Amazon SNS网址适用于浏览器,但不适用于Android应用 [英] Amazon SNS URL works on browser but not from Android app

查看:211
本文介绍了Amazon SNS网址适用于浏览器,但不适用于Android应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为亚马逊SNS做了网址。 $ b

  http://sns.ap-northeast-1.amazonaws.com ? 
AWSAccessKeyId = ***********& Action = CreatePlatformEndpoint& PlatformApplicationArn = arn%3Aaws%3Asns%3Aap-northeast-1%3A776188326341%3Aapp%2FGCM%2Fmyapplication&
是SignatureMethod = HmacSHA256&安培; SignatureVersion = 2及时间戳= 2016-03-20T23%3A08%3A26.601Z
和令牌= APA91bFN3NV_cBqPtqc6vUSYm8C6o9m5UMoUAvp3qM6WWPlef5s8G8__RNQi_AljpgTJEq-hWqF7iQYJ-4OXKiRJc1uz5JvzDIXfgWd_5AC08S_m0bOIIdcWW2cMZjAyH7PrXpSu2h9j
和版本= 2010-03- 31& Signature =%2B%2BjtNjQL7qgxUgnwJIwvxMyOdyQnxlmlHtzOJJ%2FQU6A%3D

然而,这个网址很复杂这个网址是正确的。



我把这个网址放在浏览器上,它工作正常。



然而,当我尝试这个从非常简单的应用程序中,
它返回400个错误的请求错误。

这是非常简单的钛源代码。

  var xhrSNS = Ti.Network.createHTTPClient({
onload:function(e){
Ti.API.info(testPost query:+ JSON.stringify(e));
Ti.API.info(this.responseText);
},
onerror:function(e){
Ti.API.debug( error:+ e.error);
}
});
xhrSNS.open('GET',url);
xhrSNS.send();



b
此外,我已经确认这个钛源代码是正确的。


是否有其他要点我需要检查?

解决方案

您应该检查Amazon SNS的日志,以了解为什么会触发HTTP错误400。有时Web服务器应用程序拒绝处理客户端请求,例如,由于防火墙阻止了请求,因为它没有正确的用户代理信息。这个有可能。所以你应该先从服务器端进行调查。


I made the url for amazon SNS.

http://sns.ap-northeast-1.amazonaws.com?
AWSAccessKeyId=***********&Action=CreatePlatformEndpoint&PlatformApplicationArn=arn%3Aaws%3Asns%3Aap-northeast-1%3A776188326341%3Aapp%2FGCM%2Fmyapplication&
SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2016-03-20T23%3A08%3A26.601Z
&Token=APA91bFN3NV_cBqPtqc6vUSYm8C6o9m5UMoUAvp3qM6WWPlef5s8G8__RNQi_AljpgTJEq-hWqF7iQYJ-4OXKiRJc1uz5JvzDIXfgWd_5AC08S_m0bOIIdcWW2cMZjAyH7PrXpSu2h9j
&Version=2010-03-31&Signature=%2B%2BjtNjQL7qgxUgnwJIwvxMyOdyQnxlmlHtzOJJ%2FQU6A%3D

This url looks complex however, I have confirmed this url is correct.

I put this url on browser it works fine.

However when I try this from very simple application, It returns 400 bad request error.

This is very simple titanium source code.

var xhrSNS = Ti.Network.createHTTPClient({
    onload :function(e) {
        Ti.API.info("testPost query:" + JSON.stringify(e));
        Ti.API.info(this.responseText);
    },
    onerror : function(e){
        Ti.API.debug("error:" + e.error);
        }       
});
xhrSNS.open('GET',url);
xhrSNS.send();

I just confused why the same url works on browser and not android.

Moreover, I have confiremd this titanium source code is correct.

Is there any other points I need to check??

解决方案

You should check log of Amazon SNS to know why HTTP error 400 is triggered. Sometime web server application refuse to handle client request, for example, due to firewall blocks the request because it does not have proper user agent information. This is possible. So you should investigate it from server side first.

这篇关于Amazon SNS网址适用于浏览器,但不适用于Android应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆