Advertisement
phatjk

(Autoit)Set cookie facebook in IE

Jul 22nd, 2018
419
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 1.51 KB | None | 0 0
  1. #include <_httprequest.au3>
  2. #include <string.au3>
  3. #include <ie.au3>
  4. ;############### khai báo các thứ
  5. $token = ''
  6. $cookie = TokenToCookie($token)
  7. $fb_login_js = 'javascript: void(function() {var cookie = "' & $cookie & '";var list = cookie.split("; ");for (var i = list.length - 1; i >= 0; i--) {var cname = list[i].split("=")[0];var cvalue = list[i].split("=")[1];var d = new Date();d.setTime(d.getTime() + (7 * 24 * 60 * 60 * 1000));var expires = ";domain=.facebook.com;expires=" + d.toUTCString();document.cookie = cname + "=" + cvalue + "; " + expires;}location.href = "https://facebook.com";})();'
  8. ;################
  9. $oIE = _IECreate('facebook.com')
  10. $oIE.document.parentwindow.execScript($fb_login_js)
  11.  
  12. Func TokenToCookie($token)
  13.     $codeid = _HttpRequest(2, 'https://graph.facebook.com/app?access_token=' & $token)
  14.     $id = _StringBetween($codeid, '"id": "', '"')[0]
  15.     $codecookie = _HttpRequest(2, 'https://api.facebook.com/method/auth.getSessionforApp?access_token=' & $token & '&format=json&new_app_id=' & $id & '&generate_session_cookies=1')
  16.     $tach = _StringBetween($codecookie, 'session_cookies":', '}]')[0] & "}]"
  17.     $c_user = StringRegExp($tach, '"c_user","value":"(.*?)"', 3)
  18.     $datr = StringRegExp($tach, '"datr","value":"(.*?)"', 3)
  19.     $xs = StringRegExp($tach, '"xs","value":"(.*?)"', 3)
  20.     $fr = StringRegExp($tach, '"fr","value":"(.*?)"', 3)
  21.     $cookie = ' datr=' & $datr[0] & '; c_user=' & $c_user[0] & '; xs=' & $xs[0] & '; fr=' & $fr[0] & '; pl=n;'
  22.     Return $cookie
  23. ;~     Phat rat dep trai
  24. EndFunc   ;==>TokenToCookie
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement