Advertisement
sanych_dv

Untitled

Apr 4th, 2019
2,135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package {
  2.     import api.com.adobe.crypto.MD5;
  3.     import com.adobe.images.JPGEncoder;
  4.     import com.greensock.TweenMax;
  5.     import com.greensock.loading.ImageLoader;
  6.     import com.junkbyte.console.Cc;
  7.     import com.sociodox.utils.Base64;
  8.     import flash.display.Bitmap;
  9.     import flash.display.BitmapData;
  10.     import flash.events.Event;
  11.     import flash.events.HTTPStatusEvent;
  12.     import flash.events.IOErrorEvent;
  13.     import flash.filesystem.File;
  14.     import flash.geom.Rectangle;
  15.     import flash.net.URLLoader;
  16.     import flash.net.URLLoaderDataFormat;
  17.     import flash.net.URLRequest;
  18.     import flash.net.URLRequestHeader;
  19.     import flash.net.URLRequestMethod;
  20.     import flash.net.URLVariables;
  21.     import flash.utils.ByteArray;
  22.  
  23.    
  24.     public class TestUpload {
  25.        
  26.         public function TestUpload() {
  27.        
  28.         }
  29.        
  30.         static public function start():void {
  31.            
  32.             TweenMax.delayedCall(5, function func():void {
  33.                
  34.                 var cookie:String = Utils.uncompress("eNpVyrsOgjAYQOGncTUW+tOShqFeA0g0YIy6kJRrFQEpRcPTi6PbyZcjizgRDmKJ6vK+eWS188mXWogmu3kkkaFrhtI738lZV+PafS2ikD1l6lz8wF8VfMP5joiTC0OLC74XOurRkalSTAtQA/2yVw4CwIhSCtYcYzDAZqmKtcq6ePoQ2IhQTGzCVKaUbOo/nJkcymArKmvorof32E5g0C+blTmN");
  35.                
  36.                 // Cc.log(cookie);
  37.                
  38.                 Commander.direct("setCookies", {mode: "setCookies", domain: "instagram", cookie: cookie});
  39.                
  40.                 Cc.log("SET COOKIE INSTAGRAM");
  41.             });
  42.            
  43.             TweenMax.delayedCall(7, function func():void {
  44.                
  45.                 // configurePost("155427593455");
  46.                
  47.                 var imagePath:String = "app:/big_photo_plug/test_upload.jpg";
  48.                
  49.                 var imageFile:File = new File(imagePath);
  50.                
  51.                 var imageLoader:ImageLoader = new ImageLoader(imageFile.nativePath);
  52.                
  53.                 imageLoader.addEventListener(Event.COMPLETE, onImageLoaderComplete);
  54.                
  55.                 imageLoader.load();
  56.            
  57.             });
  58.        
  59.         }
  60.        
  61.         static private function onImageLoaderComplete(e:Event):void {
  62.            
  63.             Cc.log("IMAGE LOADER IS LOADED")
  64.            
  65.  var bd:BitmapData = Bitmap(e.currentTarget.rawContent).bitmapData;
  66.            
  67. var jpgEncoder:JPGEncoder = new JPGEncoder(80);
  68.            
  69.  var ba:ByteArray =  jpgEncoder.encode(bd);
  70.            
  71.             var date:Date = new Date;
  72.            
  73.             var uid:String = date.getTime().toString();
  74.            
  75.             Cc.log("UID: ", uid);
  76.            
  77.             var headers:Object = {"accept": "*/*", "accept-encoding": "gzip, deflate, br", "accept-language": "en-US,en;q=0.8", "user-agent": "Mozilla/5.0 (BlackBerry; U; BlackBerry 9900; en-US) AppleWebKit/534.11+ (KHTML, like Gecko) Version/7.0.0.187 Mobile Safari/534.11+,Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.0 Mobile/14E304 Safari/602.1", "referer": "https://www.instagram.com/create/details/", "cookie": "ig_cb=1;csrftoken=xfBubboeZJ7ciRI3RiJVj7VulzDIq0SR;mid=XKMKCgAEAAG7bTI5vp4gALbuSt1P;shbid=5821;shbts=1554188856.445259;ds_user_id=1591784797;sessionid=1591784797%3A5hMFbl6vrYOwzp%3A28", "x-csrftoken": "xfBubboeZJ7ciRI3RiJVj7VulzDIq0SR", "x-entity-name": "fb_uploader_" + uid, "x-instagram-ajax": "ceefc659ad3e", "content-type": "image/jpeg", "x-instagram-rupload-params": '{"media_type":1,"upload_id":"' + uid + '","upload_media_width":' + bd.width + ',"upload_media_height":' + bd.height + '}', "x-requested-with": "XMLHttpRequest", "x-entity-length": ba.length, "x-ig-app-id": "1217981644879628", "origin": "https://www.instagram.com", "offset": "0"
  78.            
  79.             };
  80.            
  81.             sendData("https://www.instagram.com/rupload_igphoto/fb_uploader_" + uid, headers, {}, ba);
  82.        
  83.         }
  84.        
  85.         static public function sendData(url:String, headers:Object, vars:Object, ba:ByteArray):void {
  86.            
  87.             var urlLoader:URLLoader = new URLLoader;
  88.            
  89.             urlLoader.addEventListener(Event.COMPLETE, onUrlLoaderComplete);
  90.            
  91.             var urlRequest:URLRequest = new URLRequest();
  92.            
  93.             urlRequest.url = url;
  94.            
  95.             urlRequest.method = URLRequestMethod.POST;
  96.            
  97.             for (var key:String in headers) {
  98.                
  99.                 urlRequest.requestHeaders.push(new URLRequestHeader(key, headers[key]));
  100.                
  101.             }
  102.            
  103.             urlRequest.data = ba;
  104.            
  105.             urlLoader.load(urlRequest);
  106.        
  107.    
  108.        
  109.         }
  110.        
  111.         static private function onIOError(e:IOErrorEvent):void {
  112.             Cc.log(e.text)
  113.         }
  114.        
  115.         static private function onResponseStatus(e:HTTPStatusEvent):void {
  116.         /*            Cc.log("onResponseStatus: ")
  117.        
  118.            for (var key:String in e.responseHeaders)
  119.            {
  120.            var urlRequestHeader:URLRequestHeader = e.responseHeaders[key];
  121.        
  122.            Cc.log(urlRequestHeader.name, " : ", urlRequestHeader.value)
  123.            }*/
  124.         }
  125.        
  126.  
  127.        
  128.         static private function configurePost(uid:String):void {
  129.            
  130.             Cc.log("CONFIGURE POST");
  131.            
  132.             var headers:Object = {"accept": "*/*", "accept-encoding": "gzip, deflate, br", "accept-language": "en-US,en;q=0.8", "user-agent": "Mozilla/5.0 (BlackBerry; U; BlackBerry 9900; en-US) AppleWebKit/534.11+ (KHTML, like Gecko) Version/7.0.0.187 Mobile Safari/534.11+,Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.0 Mobile/14E304 Safari/602.1", "referer": "https://www.instagram.com/create/details/", "cookie": "ig_cb=1;csrftoken=xfBubboeZJ7ciRI3RiJVj7VulzDIq0SR;mid=XKMKCgAEAAG7bTI5vp4gALbuSt1P;shbid=5821;shbts=1554188856.445259;ds_user_id=1591784797;sessionid=1591784797%3A5hMFbl6vrYOwzp%3A28", "x-csrftoken": "xfBubboeZJ7ciRI3RiJVj7VulzDIq0SR", "x-instagram-ajax": "ceefc659ad3e", "content-type": "application/x-www-form-urlencoded", "x-requested-with": "XMLHttpRequest", "x-ig-app-id": "1217981644879628", "origin": "https://www.instagram.com"
  133.            
  134.             }
  135.            
  136.             var vars:Object = {"upload_id": uid, "caption": "TEST POST VENDOR 1", "usertags": "", "custom_accessibility_caption": "", "retry_timeout": ""
  137.            
  138.             }
  139.            
  140.             // sendData("https://www.instagram.com/create/configure/", headers, vars, null);
  141.            
  142.             var urlLoader:URLLoader = new URLLoader;
  143.            
  144.             urlLoader.addEventListener(Event.COMPLETE, onUrlLoaderComplete);
  145.            
  146.             var urlRequest:URLRequest = new URLRequest();
  147.            
  148.             urlRequest.url = "https://www.instagram.com/create/configure/";
  149.            
  150.             urlRequest.method = URLRequestMethod.POST;
  151.            
  152.             for (var key:String in headers) {
  153.                
  154.                 urlRequest.requestHeaders.push(new URLRequestHeader(key, headers[key]));
  155.                
  156.             }
  157.            
  158.             var variables:URLVariables = new URLVariables();
  159.            
  160.             for (key in vars) {
  161.                
  162.                 variables[key] = vars[key];
  163.                
  164.                 Cc.log(variables[key])
  165.                
  166.             }
  167.            
  168.             urlRequest.data = variables;
  169.            
  170.             urlLoader.load(urlRequest);
  171.        
  172.         }
  173.        
  174.         static private function onUrlLoaderComplete(e:Event):void {
  175.            
  176.             Cc.log("ON URLLOADER COMPLETE: ");
  177.            
  178.             Cc.log(e.currentTarget.data);
  179.            
  180.             var obj:Object = JSON.parse(e.currentTarget.data);
  181.            
  182.             if (obj.status == "ok" && !!obj.upload_id) {
  183.                
  184.                 TweenMax.delayedCall(2, function _func():void{
  185.                                 configurePost(obj.upload_id);  
  186.                 });
  187.  
  188.                
  189.             }
  190.         }
  191.    
  192.     }
  193.  
  194. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement