Amazon SNS URL works on browser but not from Android app

别来无恙 提交于 2019-12-13 05:35:14

问题


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??


回答1:


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.



来源:https://stackoverflow.com/questions/36121566/amazon-sns-url-works-on-browser-but-not-from-android-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!