From cb8a72626f990228c533aae22213da71555c7531 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hasan=20Y=C3=BCksektepe?= Date: Fri, 2 Apr 2021 23:13:31 +0300 Subject: [PATCH] 1.0.12 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Paylaşım beğenme ve beğenmekten çıkma yeri değiştirildi - Paylaşım kaydetme ve kaydetmekten çıkma yeri değiştirildi - Paylaşıma yorum atma eklendi - Paylaşımdan yorum silme eklendi - Paylaşımı mesaj olarak gönderme eklendi. - Takipçilerim arasından çıkartma eklendi - Giriş yapan kullanıcının istatistikleri eklendi - Gereksiz fonksiyonlar silindi. - Giriş Yapmış Kullanıcının En Az Etkileşimde Olduğu Kullanıcılar eklendi - Giriş Yapmış Kullanıcının En Çok Gördüğü Kullanıcılar --- README.md | 20 +++- src/instagram_medias.php | 224 ++++++++++++++++++++++++++++++++------- src/instagram_user.php | 85 ++++++++------- 3 files changed, 249 insertions(+), 80 deletions(-) diff --git a/README.md b/README.md index 75eee15..c5dd9f4 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,8 @@ [![Stargazers][stars-shield]][stars-url] [![Issues][issues-shield]][issues-url] [![MIT License][license-shield]][license-url] -[![LinkedIn][linkedin-shield]][linkedin-url] +[![Hasan Yüksetepe][linkedin-shield]][linkedin-url] +[![@hasokeyk][instagram-shield]][instagram-url]
@@ -162,7 +163,9 @@ paylaşımlarını getirmek için get_user_posts('hasokeyk') yazmanız yeterlidi | Profil Resmi Değiştirme | :heavy_check_mark: | [instagram-user-change-profil-pic.php](https://github.com/Hasokeyk/instagram/blob/main/examples/instagram-user-change-profil-pic.php) | | Kullanıcı Takip Etme | :heavy_check_mark: | [HAZIRLANIYOR](https://github.com/Hasokeyk/instagram/tree/main/examples) | | Kullanıcı Takipten Çıkma | :heavy_check_mark: | [HAZIRLANIYOR](https://github.com/Hasokeyk/instagram/tree/main/examples) | -| Kullanıcı İstatistikleri | :heavy_check_mark: | [HAZIRLANIYOR](https://github.com/Hasokeyk/instagram/tree/main/examples) | +| Giriş Yapmış Kullanıcı İstatistikleri | :heavy_check_mark: | [HAZIRLANIYOR](https://github.com/Hasokeyk/instagram/tree/main/examples) | +| Giriş Yapmış Kullanıcının En Az Etkileşimde Olduğu Kullanıcılar | :heavy_check_mark: | [HAZIRLANIYOR](https://github.com/Hasokeyk/instagram/tree/main/examples) | +| Giriş Yapmış Kullanıcının En Çok Gördüğü Kullanıcılar | :heavy_check_mark: | [HAZIRLANIYOR](https://github.com/Hasokeyk/instagram/tree/main/examples) | ## Paylaşım İşlemleri @@ -176,6 +179,11 @@ paylaşımlarını getirmek için get_user_posts('hasokeyk') yazmanız yeterlidi | Carousel Paylaşma | :x: | [HAZIRLANIYOR](https://github.com/Hasokeyk/instagram/tree/main/examples) | | Paylaşım Beğenme | :heavy_check_mark: | [HAZIRLANIYOR](https://github.com/Hasokeyk/instagram/tree/main/examples) | | Paylaşım Beğenmekten Çıkma | :heavy_check_mark: | [HAZIRLANIYOR](https://github.com/Hasokeyk/instagram/tree/main/examples) | +| Paylaşım Kayıt Etme | :heavy_check_mark: | [HAZIRLANIYOR](https://github.com/Hasokeyk/instagram/tree/main/examples) | +| Paylaşım Kayıt Etmekten Çıkma | :heavy_check_mark: | [HAZIRLANIYOR](https://github.com/Hasokeyk/instagram/tree/main/examples) | +| Paylaşıma Yorum Yazma | :heavy_check_mark: | [HAZIRLANIYOR](https://github.com/Hasokeyk/instagram/tree/main/examples) | +| Paylaşıma Yorum Silme | :heavy_check_mark: | [HAZIRLANIYOR](https://github.com/Hasokeyk/instagram/tree/main/examples) | +| Paylaşım Mesaj Olarak Yollama | :heavy_check_mark: | [HAZIRLANIYOR](https://github.com/Hasokeyk/instagram/tree/main/examples) | ## Mesajlaşma İşlemleri @@ -200,12 +208,12 @@ kodları yazan kişinin sorumluluğu bulunmamaktadır. Bu projeyi indirip kullan ## Bağış Yapın -patreon: https://www.patreon.com/hasokeyk?fan_landing=true +patreon: https://www.patreon.com/hasokeyk ## İletişim -Hasan Yüksektepe - [INSTAGRAM](https://instagram/hasokeyk) +Hasan Yüksektepe - [INSTAGRAM](https://instagram.com/hasokeyk) Web Sitem : [https://hayatikodla.net](https://hayatikodla.net) @@ -232,3 +240,7 @@ Web Sitem : [https://hayatikodla.net](https://hayatikodla.net) [linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge&logo=linkedin&colorB=555 [linkedin-url]: https://www.linkedin.com/in/hasan-yuksektepe/ + +[instagram-shield]: https://img.shields.io/badge/-Instagram-black.svg?style=for-the-badge&logo=Instagram&colorB=555 + +[instagram-url]: https://instagram.com/hasokeyk/ diff --git a/src/instagram_medias.php b/src/instagram_medias.php index 598e351..86292e2 100644 --- a/src/instagram_medias.php +++ b/src/instagram_medias.php @@ -30,7 +30,7 @@ public function get_post_likes($shortcode = null){ } - public function get_post_comments($shortcode = null){ + public function get_comment_post($shortcode = null){ if($shortcode != null){ @@ -68,48 +68,198 @@ public function get_user_posts($username = null){ return $result; } - public function change_profil_pic($image_path = null){ - - $upload_id = $this->functions->upload->get_upload_id(); - $upload_session_id = $this->functions->upload->get_upload_session_id($upload_id); - $url = 'https://i.instagram.com/rupload_igphoto/'.$upload_session_id; - - $file = file_get_contents($image_path); - $file_size = strlen($file); - - $header = [ - "Content-Type" => "application/octet-stream", - "X-Entity-Type" => "image/jpeg", - "X-Entity-Name" => $upload_session_id, - "Offset" => "0", - "X-Entity-Length" => $file_size, - "Cookie" => $this->create_cookie(), - "X-Instagram-Rupload-Params" => $this->functions->upload->rupload_params($upload_id), - ]; - - $json = $this->request($url, 'UPLOAD', ['body' => $file], $header); - $json = json_decode($json['body']); - if($json->status == 'ok'){ - $result = $this->_change_profil_pic($upload_id); - if($result->status == 'ok'){ - return true; + public function like($shortcode){ + + if($shortcode != null){ + + $url = 'https://i.instagram.com/api/v1/media/'.$shortcode.'/like/'; + + $post_data = [ + 'container_module' => 'feed_contextual_profile', + 'delivery_class' => 'organic', + 'radio_type' => 'wifi-none', + 'feed_position' => '0', + 'media_id' => $shortcode, + '_csrftoken' => $this->get_csrftoken(), + '_uuid' => $this->get_guid(), + ]; + $post_data = ['signed_body' => 'SIGNATURE.'.json_encode($post_data)]; + + $json = $this->request($url, 'POST', $post_data); + $json = json_decode($json['body']); + + return $json; + } + + return false; + + } + + public function unlike($shortcode){ + + if($shortcode != null){ + + $url = 'https://i.instagram.com/api/v1/media/'.$shortcode.'/unlike/'; + + $post_data = [ + 'container_module' => 'feed_contextual_profile', + 'delivery_class' => 'organic', + 'radio_type' => 'wifi-none', + 'feed_position' => '0', + 'media_id' => $shortcode, + '_csrftoken' => $this->get_csrftoken(), + '_uuid' => $this->get_guid(), + ]; + $post_data = ['signed_body' => 'SIGNATURE.'.json_encode($post_data)]; + + $json = $this->request($url, 'POST', $post_data); + $json = json_decode($json['body']); + + return $json; + } + + return false; + + } + + public function save($shortcode){ + + if($shortcode != null){ + + $url = 'https://i.instagram.com/api/v1/media/'.$shortcode.'/save/'; + + $post_data = [ + 'module_name' => 'feed_timeline', + 'radio_type' => 'wifi-none', + '_csrftoken' => $this->get_csrftoken(), + '_uuid' => $this->get_guid(), + ]; + $post_data = ['signed_body' => 'SIGNATURE.'.json_encode($post_data)]; + + $json = $this->request($url, 'POST', $post_data); + $json = json_decode($json['body']); + + return $json; + } + + return false; + + } + + public function unsave($shortcode){ + + if($shortcode != null){ + + $url = 'https://i.instagram.com/api/v1/media/'.$shortcode.'/unsave/'; + + $post_data = [ + 'module_name' => 'feed_timeline', + 'radio_type' => 'wifi-none', + '_csrftoken' => $this->get_csrftoken(), + '_uuid' => $this->get_guid(), + ]; + $post_data = ['signed_body' => 'SIGNATURE.'.json_encode($post_data)]; + + $json = $this->request($url, 'POST', $post_data); + $json = json_decode($json['body']); + + return $json; + } + + return false; + + } + + public function send_comment_post($shortcode, $comment = 'hi'){ + + if($shortcode != null){ + + $url = 'https://i.instagram.com/api/v1/media/'.$shortcode.'/comment/'; + + $post_data = [ + 'comment_text' => $comment, + 'container_module' => 'comments_v2_feed_contextual_profile', + 'delivery_class' => 'organic', + 'idempotence_token' => '455f2f7e-7abf-4236-b527-8f422f84bab0', + '_csrftoken' => $this->get_csrftoken(), + '_uuid' => $this->get_guid(), + ]; + $post_data = ['signed_body' => 'SIGNATURE.'.json_encode($post_data)]; + + $json = $this->request($url, 'POST', $post_data); + $json = json_decode($json['body']); + + return $json; + } + + return false; + + } + + public function delete_comment_post($shortcode = null, $comment_id = null, $auto_find_comment_id = false){ + + if($shortcode != null){ + + if($auto_find_comment_id == true){ + $get_comment_posts = $this->get_comment_post($shortcode); + $me_user_id = $this->functions->user->get_user_id(); + $comment_id = 0; + foreach($get_comment_posts->comments as $comment){ + if($me_user_id == $comment->user_id){ + $comment_id = $comment->pk; + break; + } + } + if($comment_id == 0){ + return false; + } } + + $url = 'https://i.instagram.com/api/v1/media/'.$shortcode.'/comment/bulk_delete/'; + + $post_data = [ + 'comment_ids_to_delete' => $comment_id, + 'container_module' => 'comments_v2_feed_contextual_profile', + '_csrftoken' => $this->get_csrftoken(), + '_uuid' => $this->get_guid(), + ]; + $post_data = ['signed_body' => 'SIGNATURE.'.json_encode($post_data)]; + + $json = $this->request($url, 'POST', $post_data); + $json = json_decode($json['body']); + + return $json; } return false; + } - protected function _change_profil_pic($upload_id){ - - $url = 'https://i.instagram.com/api/v1/accounts/change_profile_picture/'; - $post_data = [ - '_csrftoken' => $this->get_csrftoken(), - '_uuid' => $this->get_guid(), - 'use_fbuploader' => 'true', - 'upload_id' => $upload_id, - ]; - $json = $this->request($url, 'POST', $post_data); - return json_decode($json['body']); + public function share_media($shortcode = null, $username = null){ + + if($shortcode != null and $username != null){ + + $get_thread_id = $this->functions->user->get_create_inbox_thread($username); + + $url = 'https://i.instagram.com/api/v1/direct_v2/threads/broadcast/media_share/?media_type=video'; + + $post_data = [ + 'action' => 'send_item', + 'is_shh_mode' => '0', + 'send_attribution' => 'comments_v2_feed_contextual_profile', + 'thread_ids' => '['.$get_thread_id->thread->thread_id.']', + 'media_id' => $shortcode, + '_csrftoken' => $this->get_csrftoken(), + '_uuid' => $this->get_guid(), + ]; + + $json = $this->request($url, 'POST', $post_data); + $json = json_decode($json['body']); + + return $json; + } + + return false; } diff --git a/src/instagram_user.php b/src/instagram_user.php index 34bae41..0fc6294 100644 --- a/src/instagram_user.php +++ b/src/instagram_user.php @@ -137,46 +137,20 @@ public function get_user_info_by_username($username = null){ } - public function like($shortcode){ - - if($shortcode != null){ - - $url = 'https://i.instagram.com/api/v1/media/'.$shortcode.'/like/'; - - $post_data = [ - 'container_module' => 'feed_contextual_profile', - 'delivery_class' => 'organic', - 'radio_type' => 'wifi-none', - 'feed_position' => '0', - 'media_id' => $shortcode, - '_csrftoken' => $this->get_csrftoken(), - '_uuid' => $this->get_guid(), - ]; - $post_data = ['signed_body' => 'SIGNATURE.'.json_encode($post_data)]; - - $json = $this->request($url, 'POST', $post_data); - $json = json_decode($json['body']); - - return $json; - } - - return false; - - } - - public function unlike($shortcode){ + public function follow($username){ - if($shortcode != null){ + if($username != null){ + $user_id = $this->get_user_id($username); + $me_user_id = $this->get_user_id(); - $url = 'https://i.instagram.com/api/v1/media/'.$shortcode.'/unlike/'; + $url = 'https://i.instagram.com/api/v1/friendships/create/'.$user_id.'/'; $post_data = [ - 'container_module' => 'feed_contextual_profile', - 'delivery_class' => 'organic', + 'container_module' => 'self_following', 'radio_type' => 'wifi-none', - 'feed_position' => '0', - 'media_id' => $shortcode, + 'user_id' => $user_id, '_csrftoken' => $this->get_csrftoken(), + '_uid' => $me_user_id, '_uuid' => $this->get_guid(), ]; $post_data = ['signed_body' => 'SIGNATURE.'.json_encode($post_data)]; @@ -191,13 +165,13 @@ public function unlike($shortcode){ } - public function follow($username){ + public function unfollow($username){ if($username != null){ $user_id = $this->get_user_id($username); $me_user_id = $this->get_user_id(); - $url = 'https://i.instagram.com/api/v1/friendships/create/'.$user_id.'/'; + $url = 'https://i.instagram.com/api/v1/friendships/destroy/'.$user_id.'/'; $post_data = [ 'container_module' => 'self_following', @@ -219,13 +193,13 @@ public function follow($username){ } - public function unfollow($username){ + public function unfollow_me($username){ if($username != null){ $user_id = $this->get_user_id($username); $me_user_id = $this->get_user_id(); - $url = 'https://i.instagram.com/api/v1/friendships/destroy/'.$user_id.'/'; + $url = 'https://i.instagram.com/api/v1/friendships/remove_follower/'.$user_id.'/'; $post_data = [ 'container_module' => 'self_following', @@ -371,7 +345,7 @@ public function get_create_inbox_thread($username){ $user_id = $this->get_user_id($username); $url = 'https://i.instagram.com/api/v1/direct_v2/threads/get_by_participants/?recipient_users=%5B'.$user_id.'%5D&seq_id=1573&limit=20'; $json = $this->request($url, 'GET'); - //$json = json_decode($json['body']); + $json = json_decode($json['body']); return $json; } @@ -445,6 +419,39 @@ public function get_inbox_user_thread($username = null, $group = false){ } + public function get_me_least_interacted_with(){ + + $url = 'https://i.instagram.com/api/v1/friendships/smart_groups/least_interacted_with/?search_surface=follow_list_page&query=&enable_groups=true&rank_token=e667dad2-ccf4-461a-ba53-d83f9007cc7f'; + $json = $this->request($url); + $json = json_decode($json['body']); + + return $json; + + } + + public function get_me_most_seen_in_feed(){ + + $url = 'https://i.instagram.com/api/v1/friendships/smart_groups/most_seen_in_feed/?search_surface=follow_list_page&query=&enable_groups=true&rank_token=b66b8315-8421-427b-a9c8-c99a894775b6'; + $json = $this->request($url); + $json = json_decode($json['body']); + + return $json; + + } + + public function get_my_statistic(){ + + $url = 'https://i.instagram.com/api/v1/ads/graphql/?locale=tr_TR&vc_policy=insights_policy&surface=account'; + $post_var = [ + 'variables' => '{"query_params":{"access_token":"","id":"7573271439"},"timezone":"Asia/Bahrain"}', + 'doc_id' => '1706456729417729', + ]; + $json = $this->request($url, 'POST', $post_var); + $json = json_decode($json['body']); + + return $json; + + } private function generate_client_context(){ return (round(microtime(true) * 1000) << 22 | random_int(PHP_INT_MIN, PHP_INT_MAX) & 4194303) & PHP_INT_MAX;