How to get HTTP interface data in an HTTPS Web site via a picture

Source: Internet
Author: User

<script>
(function () {
var decode=function (b) {var e;e=[];var a=b.width,c=b.height,d=document.createelement ("Canvas");d. width=a;d.height= C;d=d.getcontext ("2d");d. DrawImage (b,0,0); B=d.getimagedata (0,0,a,c); for (d=0;d<a*c*4;d+=4) [].push.apply (e,[] . Slice.call (B.data,d,d+3)); for (A=e.length-1;0===e[a];) e=e.slice (0,a), a--;a= ""; for (c=0;c<e.length;c+=7) for (b =0;8>b;b++) d= ((0==b?0:e[c+b-1]) <<7-b&127) + ((7==b?0:e[c+b]) >>b+1), A+=0==d? "": String.fromCharCode (d); return a};

function GetIP (callback) {
var img = new Image ();
Img.onload = function () {
Callback (Decode (this));
};
Img.onerror = function () {
Alert (' interface failed to load ... ‘);
};
Img.crossorigin = ' * ';
IMG.SRC = ' http://ip.qgy18.com:81/?png=1&_= ' + math.random ();
}

document.getElementById (' Get-ip '). AddEventListener (' click ', function () {
var el = document.getElementById (' Ip-info ');
el.innerhtml = ' loading ... ';
GetIP (function (d) {
D = Json.parse (d);
el.innerhtml = ' IP info: ' + d.ip + ', ' + d.address;
});
});
})();
</script>

<p> This example shows how to get HTTP interface data from an HTTPS Web site using a picture and use a Canvas. In fact, if the return value can be enumerated, even the Canvas can be saved-the server directly generated a wide 1px, high npx picture, JS get the image height can know the return value. </p>

Original: https://imququ.com/post/use-image-to-transfer-data.html

How to get HTTP interface data in an HTTPS Web site via a picture

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.