Advertisement
Guest User

Untitled

a guest
Apr 16th, 2016
1,113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.47 KB | None | 0 0
  1. <?php
  2. require_once("instagram.php");
  3. $username = 'ТУТ ЛОГИН';
  4. $password = 'ТУТ ПАРОЛЬ';
  5. $agent = 'Instagram 6.21.2 Android (19/4.4.2; 480dpi; 1152x1920; Meizu; MX4; mx4; mt6595; en_US)';
  6. $guid = GenerateGuid();
  7. $device_id = "android-".$guid;
  8. $data ='{"device_id":"'.$device_id.'","guid":"'.$guid.'","username":"'.$username.'","password":"'.$password.'","Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"}';
  9. $sig = GenerateSignature($data);
  10. $data = 'signed_body='.$sig.'.'.urlencode($data).'&ig_sig_key_version=6';
  11. $login = SendRequest('accounts/login/', true, $data, $agent, false);
  12. print_r($login);
  13. // Со входомом все ОК
  14.  
  15.  
  16. $data = '{"user_id":"'.$user_id.'","device_id":"'.$device_id.'","guid":"'.$guid.'","device_timestamp":"'.time().'","Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"}';
  17. $sig = GenerateSignature($data);
  18. $new_data = 'signed_body='.$sig.'.'.urlencode($data).'&ig_sig_key_version=6';
  19. $follow = SendRequest('friendships/create/1417795125', true, $new_data, $agent, true);
  20. print_r($follow);
  21. //А тут выдает
  22. //Array ( [0] => 400 [1] => {"status":"fail","message":"Please update your Instagram app to continue following."} )
  23. ?>
  24.  
  25. <?php
  26. function SendRequest($url, $post, $post_data, $user_agent, $cookies) {
  27.  
  28. $ch = curl_init();
  29. curl_setopt($ch, CURLOPT_URL, 'https://i.instagram.com/api/v1/'.$url);
  30. /*
  31. curl_setopt($ch, CURLOPT_PROXY, $proxy);
  32. curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxyauth);
  33. */
  34. curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
  35. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  36. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  37.  
  38. if($post) {
  39. curl_setopt($ch, CURLOPT_POST, true);
  40. curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
  41. }
  42.  
  43. if($cookies) {
  44. curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookies.txt');
  45. } else {
  46. curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookies.txt');
  47. }
  48.  
  49. $response = curl_exec($ch);
  50. $http = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  51. curl_close($ch);
  52. return array($http, $response);
  53. }
  54. function GenerateGuid() {
  55. return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
  56. mt_rand(0, 65535),
  57. mt_rand(0, 65535),
  58. mt_rand(0, 65535),
  59. mt_rand(16384, 20479),
  60. mt_rand(32768, 49151),
  61. mt_rand(0, 65535),
  62. mt_rand(0, 65535),
  63. mt_rand(0, 65535));
  64. }
  65. function GenerateSignature($data) {
  66. return hash_hmac('sha256', $data, '25eace5393646842f0d0c3fb2ac7d3cfa15c052436ee86b5406a8433f54d24a5');
  67. }
  68. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement