Advertisement
Guest User

Untitled

a guest
Jul 4th, 2017
380
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.63 KB | None | 0 0
  1. <?php
  2. /**
  3. *
  4. * @ This file is created by http://DeZender.Net
  5. * @ deZender (PHP5 Decoder for ionCube Encoder)
  6. *
  7. * @ Version : 3.0.7.0
  8. * @ Author : DeZender
  9. * @ Release on : 22.06.2017
  10. * @ Official site : http://DeZender.Net
  11. *
  12. */
  13.  
  14. $dizin = $_SERVER['DOCUMENT_ROOT'] . '/license.php';
  15. include $dizin;
  16. $lisans['site'] = getenv( 'HTTP_HOST' );
  17.  
  18. if (substr( $lisans['site'], 0, 4 ) == 'www.') {
  19. $lisans['site'] = substr( $lisans['site'], 4 );
  20. }
  21.  
  22. $bas = 'Ä°NSTASCRÄ°PT-';
  23. $des = '-RYBO58D-';
  24. $yil = date( Y );
  25. $son = '-';
  26. $s = 'md5';
  27. $m = 'sha1';
  28. $a = 'md5';
  29. $q = strtoupper( $s( $m( $s( $lisans['site'] ) ) ) );
  30. $bos = substr( $q, 5, 7 );
  31. $lisans['hash'] = wordwrap( strtoupper( $s( $a( $s( $a( $m( $s( $a( $m( $lisans['site'] . date( 'YmdH' ) ) ) ) ) ) ) ) ) ), 7, '-', true );
  32. $liskod = $lisans['hash'];
  33. $cevir = strrev( $liskod );
  34. $bcs = $bas . $bos . $des . $cevir . $son . $yil;
  35.  
  36. if ($bcs !== $lisanskodu) {
  37. $lisans_cevap = 'http://www.etkilibey.com/kontrol.php?site=' . $lisans['site'];
  38. $ch = curl_init( );
  39. curl_setopt( $ch, CURLOPT_URL, $lisans_cevap );
  40. curl_setopt( $ch, CURLOPT_HEADER, false );
  41. curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
  42. curl_setopt( $ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT'] );
  43. curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
  44. $lisans_cevap = curl_exec( $ch );
  45. curl_close( $ch );
  46.  
  47. if ($lisans_cevap != '1') {
  48. echo '<iframe src="http://www.etkilibey.com/lshata.php" style="position:fixed; top:0px; left:0px; bottom:0px; right:0px; width:100%; height:100%; border:none; margin:0; padding:0; overflow:hidden; z-index:999999;">' . "\n" . '</iframe>';
  49. exit( );
  50. }
  51. else {
  52. $lyaz = fopen( $dizin, 'w+' );
  53. @fwrite( $lyaz, '<?php' . "\n" . '/**' . "\n\t\n" . ' Bu dosyaya herhangi bir lisans kodu yazmaniz gerekmez' . "\n" . ' Almis oldugunuz urune ait lisans sistemde aktif oldugunda' . "\n" . ' Lisans kodunuz otomatik olarak girilecektir.' . "\n\t\n" . ' Yeni lisans almak icin www.etkilibey.com adresini ziyaret edebilirsiniz' . "\n" . ' ' . "\n" . '*/' . "\n" . '$lisanskodu="' . $bcs . '";' . "\n" . '?>' );
  54. fclose( $lyaz );
  55. }
  56. }
  57.  
  58. define( 'INSTAWEB_VERSION', str_replace( 'InstaWebV', '', basename( __FILE__, '.php' ) ) );
  59.  
  60. class Instagram
  61. {
  62. protected $username = null;
  63. protected $password = null;
  64. protected $debug = null;
  65. protected $uuid = null;
  66. protected $device_id = null;
  67. protected $username_id = null;
  68. /**
  69. * @var Settings
  70. */
  71. public $settings = null;
  72. protected $userAgent = null;
  73. protected $token = null;
  74. protected $isLoggedIn = false;
  75. protected $rank_token = null;
  76. protected $IGDataPath = null;
  77.  
  78. /**
  79. * Default class constructor.
  80. *
  81. * @param string $username
  82. * Your Instagram username.
  83. * @param string $password
  84. * Your Instagram password.
  85. * @param $debug
  86. * Debug on or off, false by default.
  87. * @param $IGDataPath
  88. * Default folder to store data, you can change it.
  89. */
  90. public function __construct($username, $password, $debug = false, $IGDataPath = NULL)
  91. {
  92. $username = trim( $username );
  93. $password = trim( $password );
  94. $this->debug = $debug;
  95. $this->device_id = SignatureUtils::generateDeviceId( md5( $username . $password ) );
  96.  
  97. if (!(is_null( $IGDataPath ))) {
  98. $this->IGDataPath = $IGDataPath;
  99. }
  100. else {
  101. $this->IGDataPath = Wow::get( 'project/cookiePath' ) . 'instagram/';
  102. }
  103.  
  104. $this->checkSettings( $username );
  105. $this->setUser( $username, $password );
  106. }
  107.  
  108. /**
  109. * Set the user. Manage multiple accounts.
  110. *
  111. * @param string $username
  112. * Your Instagram username.
  113. * @param string $password
  114. * Your Instagram password.
  115. */
  116. public function setUser($username, $password)
  117. {
  118. $this->username = $username;
  119. $this->password = $password;
  120. $this->checkSettings( $username );
  121. $this->uuid = SignatureUtils::generateUUID( true );
  122. if (file_exists( $this->IGDataPath . (string) $this->username . '.dat' ) && ($this->settings->get( 'username_id' ) != NULL) && ($this->settings->get( 'token' ) != NULL)) {
  123. $this->isLoggedIn = true;
  124. $this->username_id = $this->settings->get( 'username_id' );
  125. $this->rank_token = $this->username_id . '_' . $this->uuid;
  126. $this->token = $this->settings->get( 'token' );
  127. }
  128. else {
  129. $this->isLoggedIn = false;
  130. }
  131. }
  132.  
  133. protected function checkSettings($username)
  134. {
  135. $this->settings = new Settings( $this->IGDataPath . $username . '.cnf' );
  136.  
  137. if ($this->settings->get( 'version' ) == NULL) {
  138. $this->settings->set( 'version', Constants::VERSION );
  139. }
  140.  
  141. if ($this->settings->get( 'ip' ) == NULL) {
  142. $this->settings->set( 'ip', '78.' . rand( 160, 191 ) . '.' . rand( 1, 255 ) . '.' . rand( 1, 255 ) );
  143. }
  144.  
  145. if (($this->settings->get( 'user_agent' ) == NULL) || (version_compare( $this->settings->get( 'version' ), Constants::VERSION ) == -1)) {
  146. $userAgent = new UserAgent( $this );
  147. $ua = $userAgent->buildUserAgent( );
  148. $this->settings->set( 'version', Constants::VERSION );
  149. $this->settings->set( 'user_agent', $ua );
  150. }
  151.  
  152. $this->userAgent = $this->settings->get( 'user_agent' );
  153. }
  154.  
  155. public function getData()
  156. {
  157. return array(
  158. 'username' => $this->username,
  159. 'password' => $this->password,
  160. 'username_id' => $this->username_id,
  161. 'uuid' => $this->uuid,
  162. 'token' => $this->token,
  163. 'rank_token' => $this->rank_token,
  164. 'user_agent' => $this->userAgent,
  165. 'ip' => $this->settings->get( 'ip' )
  166. );
  167. }
  168.  
  169. /**
  170. * Login to Instagram.
  171. *
  172. * @param bool $force
  173. * Force login to Instagram, this will create a new session
  174. *
  175. * @return array
  176. * Login data
  177. */
  178. public function login($force = false)
  179. {
  180. if (!($this->isLoggedIn) || $force) {
  181. $fetch = $this->request( 'si/fetch_headers/?challenge_type=signup&guid=' . SignatureUtils::generateUUID( false ), NULL, true );
  182. preg_match( '#Set-Cookie: csrftoken=([^;]+)#', $fetch[0], $token );
  183. $data = array(
  184. 'phone_id' => SignatureUtils::generateUUID( true ),
  185. '_csrftoken' => $token[0],
  186. 'username' => $this->username,
  187. 'guid' => $this->uuid,
  188. 'device_id' => $this->device_id,
  189. 'password' => $this->password,
  190. 'login_attempt_count' => '0'
  191. );
  192. $login = $this->request( 'accounts/login/', SignatureUtils::generateSignature( json_encode( $data ) ), true );
  193.  
  194. if ($login[1]['status'] == 'fail') {
  195. throw new Exception( $login[1]['message'] );
  196. }
  197.  
  198. $this->isLoggedIn = true;
  199. $this->username_id = $login[1]['logged_in_user']['pk'];
  200. $this->settings->set( 'username_id', $this->username_id );
  201. $this->rank_token = $this->username_id . '_' . $this->uuid;
  202. preg_match( '#Set-Cookie: csrftoken=([^;]+)#', $login[0], $match );
  203. $this->token = $match[1];
  204. $this->settings->set( 'token', $this->token );
  205. $this->syncFeatures( );
  206. $this->autoCompleteUserList( );
  207. $this->timelineFeed( );
  208. $this->getRankedRecipients( );
  209. $this->getRecentRecipients( );
  210. $this->megaphoneLog( );
  211. $this->getv2Inbox( );
  212. $this->getRecentActivity( );
  213. $this->getReelsTrayFeed( );
  214. $this->explore( );
  215. return $login[1];
  216. }
  217.  
  218. $check = $this->timelineFeed( );
  219.  
  220. if (isset( $check['message'] ) && ($check['message'] == 'login_required')) {
  221. return $this->login( true );
  222. }
  223.  
  224. $this->autoCompleteUserList( );
  225. $this->getReelsTrayFeed( );
  226. $this->getRankedRecipients( );
  227. $this->getRecentRecipients( );
  228. $this->megaphoneLog( );
  229. $this->getv2Inbox( );
  230. $this->getRecentActivity( );
  231. $this->explore( );
  232. return array( 'status' => 'ok' );
  233. }
  234.  
  235. public function syncFeatures()
  236. {
  237. $data = json_encode( array(
  238. '_uuid' => $this->uuid,
  239. '_uid' => $this->username_id,
  240. 'id' => $this->username_id,
  241. '_csrftoken' => $this->token,
  242. 'experiments' => Constants::EXPERIMENTS
  243. ) );
  244. return $this->request( 'qe/sync/', SignatureUtils::generateSignature( $data ) )[1];
  245. }
  246.  
  247. protected function autoCompleteUserList()
  248. {
  249. return $this->request( 'friendships/autocomplete_user_list/' )[1];
  250. }
  251.  
  252. protected function timelineFeed()
  253. {
  254. return $this->request( 'feed/timeline/' )[1];
  255. }
  256.  
  257. protected function megaphoneLog()
  258. {
  259. return $this->request( 'megaphone/log/' )[1];
  260. }
  261.  
  262. protected function expose()
  263. {
  264. $data = json_encode( array(
  265. '_uuid' => $this->uuid,
  266. '_uid' => $this->username_id,
  267. 'id' => $this->username_id,
  268. '_csrftoken' => $this->token,
  269. 'experiment' => 'ig_android_profile_contextual_feed'
  270. ) );
  271. $this->request( 'qe/expose/', SignatureUtils::generateSignature( $data ) );
  272. $this->request( 'qe/expose/', SignatureUtils::generateSignature( $data ) )[1];
  273. }
  274.  
  275. /**
  276. * Login to Instagram.
  277. *
  278. * @return bool
  279. * Returns true if logged out correctly
  280. */
  281. public function logout()
  282. {
  283. $logout = $this->request( 'accounts/logout/' );
  284.  
  285. if ($logout == 'ok') {
  286. return true;
  287. }
  288.  
  289. return false;
  290. }
  291.  
  292. /**
  293. * Upload photo to Instagram.
  294. *
  295. * @param string $photo
  296. * Path to your photo
  297. * @param string $caption
  298. * Caption to be included in your photo.
  299. *
  300. * @return array
  301. * Upload data
  302. */
  303. public function uploadPhoto($photo, $caption = NULL, $upload_id = NULL)
  304. {
  305. $endpoint = Constants::API_URL . 'upload/photo/';
  306. $boundary = $this->uuid;
  307.  
  308. if (!(is_null( $upload_id ))) {
  309. $fileToUpload = Utils::createVideoIcon( $photo );
  310. }
  311. else {
  312. $upload_id = number_format( round( microtime( true ) * 1000 ), 0, '', '' );
  313. $fileToUpload = file_get_contents( $photo );
  314. }
  315.  
  316. $bodies = array(
  317. array(
  318. 'type' => 'form-data',
  319. 'name' => 'upload_id',
  320. 'data' => $upload_id
  321. ),
  322. array(
  323. 'type' => 'form-data',
  324. 'name' => '_uuid',
  325. 'data' => $this->uuid
  326. ),
  327. array(
  328. 'type' => 'form-data',
  329. 'name' => '_csrftoken',
  330. 'data' => $this->token
  331. ),
  332. array(
  333. 'type' => 'form-data',
  334. 'name' => 'image_compression',
  335. 'data' => '{"lib_name":"jt","lib_version":"1.3.0","quality":"70"}'
  336. ),
  337. array(
  338. 'type' => 'form-data',
  339. 'name' => 'photo',
  340. 'data' => $fileToUpload,
  341. 'filename' => 'pending_media_' . number_format( round( microtime( true ) * 1000 ), 0, '', '' ) . '.jpg',
  342. 'headers' => array(
  343. 'Content-Transfer-Encoding: binary',
  344. 'Content-type: application/octet-stream'
  345. )
  346. )
  347. );
  348. $data = $this->buildBody( $bodies, $boundary );
  349. $headers = array(
  350. 'X-IG-Capabilities: ' . Constants::X_IG_Capabilities,
  351. 'X-IG-Connection-Type: WIFI',
  352. 'Content-type: multipart/form-data; boundary=' . $boundary,
  353. 'Content-Length: ' . strlen( $data ),
  354. 'Accept-Language: tr-TR',
  355. 'Accept-Encoding: gzip, deflate',
  356. 'Connection: close',
  357. 'X_FORWARDED_FOR: ' . $this->settings->get( 'ip' ),
  358. 'REMOTE_ADDR: ' . $this->settings->get( 'ip' )
  359. );
  360. $ch = curl_init( );
  361. curl_setopt( $ch, CURLOPT_URL, $endpoint );
  362. curl_setopt( $ch, CURLOPT_USERAGENT, $this->userAgent );
  363. curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
  364. curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
  365. curl_setopt( $ch, CURLOPT_HEADER, true );
  366. curl_setopt( $ch, CURLOPT_VERBOSE, $this->debug );
  367. curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
  368. curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false );
  369. curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers );
  370. curl_setopt( $ch, CURLOPT_COOKIEFILE, $this->IGDataPath . (string) $this->username . '.dat' );
  371. curl_setopt( $ch, CURLOPT_COOKIEJAR, $this->IGDataPath . (string) $this->username . '.dat' );
  372. curl_setopt( $ch, CURLOPT_POST, true );
  373. curl_setopt( $ch, CURLOPT_POSTFIELDS, $data );
  374. $resp = curl_exec( $ch );
  375. $header_len = curl_getinfo( $ch, CURLINFO_HEADER_SIZE );
  376. $header = substr( $resp, 0, $header_len );
  377. $upload = json_decode( substr( $resp, $header_len ), true );
  378. curl_close( $ch );
  379.  
  380. if ($upload['status'] == 'fail') {
  381. throw new Exception( $upload['message'] );
  382. }
  383.  
  384. if ($this->debug) {
  385. echo 'RESPONSE: ' . substr( $resp, $header_len ) . "\n\n";
  386. }
  387.  
  388. $configure = $this->configure( $upload['upload_id'], $photo, $caption );
  389. $this->expose( );
  390. return $configure;
  391. }
  392.  
  393. public function uploadVideo($video, $caption = NULL)
  394. {
  395. $videoData = file_get_contents( $video );
  396. $endpoint = Constants::API_URL . 'upload/video/';
  397. $boundary = $this->uuid;
  398. $upload_id = round( microtime( true ) * 1000 );
  399. $bodies = array(
  400. array(
  401. 'type' => 'form-data',
  402. 'name' => 'upload_id',
  403. 'data' => $upload_id
  404. ),
  405. array(
  406. 'type' => 'form-data',
  407. 'name' => '_csrftoken',
  408. 'data' => $this->token
  409. ),
  410. array(
  411. 'type' => 'form-data',
  412. 'name' => 'media_type',
  413. 'data' => '2'
  414. ),
  415. array(
  416. 'type' => 'form-data',
  417. 'name' => '_uuid',
  418. 'data' => $this->uuid
  419. )
  420. );
  421. $data = $this->buildBody( $bodies, $boundary );
  422. $headers = array(
  423. 'Connection: keep-alive',
  424. 'Accept: */*',
  425. 'Host: i.instagram.com',
  426. 'Content-type: multipart/form-data; boundary=' . $boundary,
  427. 'Accept-Language: tr-TR',
  428. 'X_FORWARDED_FOR: ' . $this->settings->get( 'ip' ),
  429. 'REMOTE_ADDR: ' . $this->settings->get( 'ip' )
  430. );
  431. $ch = curl_init( );
  432. curl_setopt( $ch, CURLOPT_URL, $endpoint );
  433. curl_setopt( $ch, CURLOPT_USERAGENT, $this->userAgent );
  434. curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
  435. curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
  436. curl_setopt( $ch, CURLOPT_HEADER, true );
  437. curl_setopt( $ch, CURLOPT_VERBOSE, false );
  438. curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers );
  439. curl_setopt( $ch, CURLOPT_COOKIEFILE, $this->IGDataPath . (string) $this->username . '.dat' );
  440. curl_setopt( $ch, CURLOPT_COOKIEJAR, $this->IGDataPath . (string) $this->username . '.dat' );
  441. curl_setopt( $ch, CURLOPT_POST, true );
  442. curl_setopt( $ch, CURLOPT_POSTFIELDS, $data );
  443. $resp = curl_exec( $ch );
  444. $header_len = curl_getinfo( $ch, CURLINFO_HEADER_SIZE );
  445. $body = json_decode( substr( $resp, $header_len ), true );
  446. $uploadUrl = $body['video_upload_urls'][3]['url'];
  447. $job = $body['video_upload_urls'][3]['job'];
  448. $request_size = floor( strlen( $videoData ) / 4 );
  449. $lastRequestExtra = strlen( $videoData ) - ($request_size * 4);
  450. $a = 0;
  451.  
  452. while ($a <= 3) {
  453. $start = $a * $request_size;
  454. $end = (($a + 1) * $request_size) + (($a == 3 ? $lastRequestExtra : 0));
  455. $headers = array(
  456. 'Connection: keep-alive',
  457. 'Accept: */*',
  458. 'Host: upload.instagram.com',
  459. 'Cookie2: $Version=1',
  460. 'Accept-Encoding: gzip, deflate',
  461. 'Content-Type: application/octet-stream',
  462. 'Session-ID: ' . $upload_id,
  463. 'Accept-Language: tr-TR',
  464. 'Content-Disposition: attachment; filename="video.mov"',
  465. 'Content-Length: ' . ($end - $start),
  466. 'Content-Range: ' . 'bytes ' . $start . '-' . ($end - 1) . '/' . strlen( $videoData ),
  467. 'job: ' . $job
  468. );
  469. $ch = curl_init( );
  470. curl_setopt( $ch, CURLOPT_URL, $uploadUrl );
  471. curl_setopt( $ch, CURLOPT_USERAGENT, $this->userAgent );
  472. curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, 'POST' );
  473. curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
  474. curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
  475. curl_setopt( $ch, CURLOPT_HEADER, true );
  476. curl_setopt( $ch, CURLOPT_VERBOSE, false );
  477. curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers );
  478. curl_setopt( $ch, CURLOPT_COOKIEFILE, $this->IGDataPath . (string) $this->username . '.dat' );
  479. curl_setopt( $ch, CURLOPT_COOKIEJAR, $this->IGDataPath . (string) $this->username . '.dat' );
  480. curl_setopt( $ch, CURLOPT_POST, true );
  481. curl_setopt( $ch, CURLOPT_POSTFIELDS, substr( $videoData, $start, $end ) );
  482. $result = curl_exec( $ch );
  483. $header_len = curl_getinfo( $ch, CURLINFO_HEADER_SIZE );
  484. $body = substr( $result, $header_len );
  485. $array[] = array( $body );
  486. ++$a;
  487. }
  488.  
  489. $resp = curl_exec( $ch );
  490. $header_len = curl_getinfo( $ch, CURLINFO_HEADER_SIZE );
  491. $header = substr( $resp, 0, $header_len );
  492. $upload = json_decode( substr( $resp, $header_len ), true );
  493. curl_close( $ch );
  494.  
  495. if ($upload['status'] == 'fail') {
  496. throw new Exception( $upload['message'] );
  497. }
  498.  
  499. if ($this->debug) {
  500. echo 'RESPONSE: ' . substr( $resp, $header_len ) . "\n\n";
  501. }
  502.  
  503. $configure = $this->configureVideo( $upload_id, $video, $caption );
  504. $this->expose( );
  505. return $configure;
  506. }
  507.  
  508. public function direct_message($recipients, $text)
  509. {
  510. if (!(is_array( $recipients ))) {
  511. $recipients = array( $recipients );
  512. }
  513.  
  514. $string = array( );
  515.  
  516. foreach ($recipients as $recipient) {
  517. $string[] = '"' . $recipient . '"';
  518. }
  519.  
  520. $recipient_users = implode( ',', $string );
  521. $endpoint = Constants::API_URL . 'direct_v2/threads/broadcast/text/';
  522. $boundary = $this->uuid;
  523. $bodies = array(
  524. array(
  525. 'type' => 'form-data',
  526. 'name' => 'recipient_users',
  527. 'data' => '[[' . $recipient_users . ']]'
  528. ),
  529. array(
  530. 'type' => 'form-data',
  531. 'name' => 'client_context',
  532. 'data' => $this->uuid
  533. ),
  534. array(
  535. 'type' => 'form-data',
  536. 'name' => 'thread_ids',
  537. 'data' => '["0"]'
  538. ),
  539. array(
  540. 'type' => 'form-data',
  541. 'name' => 'text',
  542. 'data' => (is_null( $text ) ? '' : $text)
  543. )
  544. );
  545. $data = $this->buildBody( $bodies, $boundary );
  546. $headers = array(
  547. 'Proxy-Connection: keep-alive',
  548. 'Connection: keep-alive',
  549. 'Accept: */*',
  550. 'Content-type: multipart/form-data; boundary=' . $boundary,
  551. 'Accept-Language: tr-TR'
  552. );
  553. $ch = curl_init( );
  554. curl_setopt( $ch, CURLOPT_URL, $endpoint );
  555. curl_setopt( $ch, CURLOPT_USERAGENT, $this->userAgent );
  556. curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
  557. curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
  558. curl_setopt( $ch, CURLOPT_HEADER, true );
  559. curl_setopt( $ch, CURLOPT_VERBOSE, $this->debug );
  560. curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
  561. curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false );
  562. curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers );
  563. curl_setopt( $ch, CURLOPT_COOKIEFILE, $this->IGDataPath . (string) $this->username . '.dat' );
  564. curl_setopt( $ch, CURLOPT_COOKIEJAR, $this->IGDataPath . (string) $this->username . '.dat' );
  565. curl_setopt( $ch, CURLOPT_POST, true );
  566. curl_setopt( $ch, CURLOPT_POSTFIELDS, $data );
  567. $resp = curl_exec( $ch );
  568. $header_len = curl_getinfo( $ch, CURLINFO_HEADER_SIZE );
  569. $header = substr( $resp, 0, $header_len );
  570. $upload = json_decode( substr( $resp, $header_len ), true );
  571. curl_close( $ch );
  572. }
  573.  
  574. public function direct_share($media_id, $recipients, $text = NULL)
  575. {
  576. if (!(is_array( $recipients ))) {
  577. $recipients = array( $recipients );
  578. }
  579.  
  580. $string = array( );
  581.  
  582. foreach ($recipients as $recipient) {
  583. $string[] = '"' . $recipient . '"';
  584. }
  585.  
  586. $recipient_users = implode( ',', $string );
  587. $endpoint = Constants::API_URL . 'direct_v2/threads/broadcast/media_share/?media_type=photo';
  588. $boundary = $this->uuid;
  589. $bodies = array(
  590. array(
  591. 'type' => 'form-data',
  592. 'name' => 'media_id',
  593. 'data' => $media_id
  594. ),
  595. array(
  596. 'type' => 'form-data',
  597. 'name' => 'recipient_users',
  598. 'data' => '[[' . $recipient_users . ']]'
  599. ),
  600. array(
  601. 'type' => 'form-data',
  602. 'name' => 'client_context',
  603. 'data' => $this->uuid
  604. ),
  605. array(
  606. 'type' => 'form-data',
  607. 'name' => 'thread_ids',
  608. 'data' => '["0"]'
  609. ),
  610. array(
  611. 'type' => 'form-data',
  612. 'name' => 'text',
  613. 'data' => (is_null( $text ) ? '' : $text)
  614. )
  615. );
  616. $data = $this->buildBody( $bodies, $boundary );
  617. $headers = array(
  618. 'Proxy-Connection: keep-alive',
  619. 'Connection: keep-alive',
  620. 'Accept: */*',
  621. 'Content-type: multipart/form-data; boundary=' . $boundary,
  622. 'Accept-Language: tr-TR'
  623. );
  624. $ch = curl_init( );
  625. curl_setopt( $ch, CURLOPT_URL, $endpoint );
  626. curl_setopt( $ch, CURLOPT_USERAGENT, $this->userAgent );
  627. curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
  628. curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
  629. curl_setopt( $ch, CURLOPT_HEADER, true );
  630. curl_setopt( $ch, CURLOPT_VERBOSE, $this->debug );
  631. curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
  632. curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false );
  633. curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers );
  634. curl_setopt( $ch, CURLOPT_COOKIEFILE, $this->IGDataPath . (string) $this->username . '.dat' );
  635. curl_setopt( $ch, CURLOPT_COOKIEJAR, $this->IGDataPath . (string) $this->username . '.dat' );
  636. curl_setopt( $ch, CURLOPT_POST, true );
  637. curl_setopt( $ch, CURLOPT_POSTFIELDS, $data );
  638. $resp = curl_exec( $ch );
  639. $header_len = curl_getinfo( $ch, CURLINFO_HEADER_SIZE );
  640. $header = substr( $resp, 0, $header_len );
  641. $upload = json_decode( substr( $resp, $header_len ), true );
  642. curl_close( $ch );
  643. }
  644.  
  645. protected function configureVideo($upload_id, $video, $caption = '')
  646. {
  647. $this->uploadPhoto( $video, $caption, $upload_id );
  648. list($size) = getimagesize( $video );
  649. $post = json_encode( array(
  650. 'upload_id' => $upload_id,
  651. 'source_type' => '3',
  652. 'poster_frame_index' => 0,
  653. 'length' => 0,
  654. 'audio_muted' => false,
  655. 'filter_type' => '0',
  656. 'video_result' => 'deprecated',
  657. 'clips' => array(
  658. 'length' => Utils::getSeconds( $video ),
  659. 'source_type' => '3',
  660. 'camera_position' => 'back'
  661. ),
  662. 'extra' => array(
  663. 'source_width' => 960,
  664. 'source_height' => 1280
  665. ),
  666. 'device' => array(
  667. 'manufacturer' => 'Xiaomi',
  668. ...............................................................
  669. ...................................
  670. ................
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement