Skip to content

Commit

Permalink
1.0.16
Browse files Browse the repository at this point in the history
- Fotoğraf paylaşma eklendi
- Readme hatalı linkler düzeltildi.
- Kullanıcı üye olma eklendi
- Kullanıcının eski kullanıcı adlarını getirme eklendi
  • Loading branch information
Hasokeyk committed May 1, 2021
1 parent af98cb9 commit fd6ad34
Show file tree
Hide file tree
Showing 7 changed files with 237 additions and 14 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,12 @@ paylaşımlarını getirmek için get_user_posts('hasokeyk') yazmanız yeterlidi
| Giriş Yapmış Kullanıcı Bilgisi Getirme | :heavy_check_mark: | [instagram-user-info.php](https://github.com/Hasokeyk/instagram/blob/main/examples/user/instagram-user-info.php) |
| Giriş Yapmış Kullanıcı İstatistik Getirme | :heavy_check_mark: | [instagram-user-statistics.php](https://github.com/Hasokeyk/instagram/blob/main/examples/user/instagram-user-statistics.php) |
| Giriş Yapmış Kullanıcının En Az Etkileşimde Olduğu Kullanıcılar | :heavy_check_mark: | [instagram-user-least-interacted-with.php](https://github.com/Hasokeyk/instagram/blob/main/examples/user/instagram-user-least-interacted-with.php) |
| Giriş Yapmış Kullanıcının En Çok Gördüğü Kullanıcılar | :heavy_check_mark: | [instagram-user-me-most-seen-in-feed.php](https://github.com/Hasokeyk/instagram/blob/main/examples/user/instagram-user-least-interacted-with.php) |
| 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: | [instagram-user-follow.php](https://github.com/Hasokeyk/instagram/blob/main/examples/instagram-user-follow.php) |
| Kullanıcı Takipten Çıkma | :heavy_check_mark: | [instagram-user-follow.php](https://github.com/Hasokeyk/instagram/blob/main/examples/instagram-user-follow.php) |
| Kullanıcının Kendisini Takipten Çıkma | :heavy_check_mark: | [instagram-user-follow.php](https://github.com/Hasokeyk/instagram/blob/main/examples/instagram-user-follow.php) |
| Kullanıcı Bildirim Listesi Getirme | :heavy_check_mark: | [instagram-user-me-notification.php](https://github.com/Hasokeyk/instagram/blob/main/examples/user/instagram-user-me-notification.php) |
| Giriş Yapmış Kullanıcının En Çok Gördüğü Kullanıcılar | :heavy_check_mark: | [instagram-user-my-most-seen-in-feed.php](https://github.com/Hasokeyk/instagram/blob/main/examples/user/instagram-user-least-interacted-with.php) |
| Profil Resmi Değiştirme | :heavy_check_mark: | [instagram-user-change-profil-pic.php](https://github.com/Hasokeyk/instagram/blob/main/examples/user/instagram-user-change-profil-pic.php) |
| Kullanıcı Takip Etme | :heavy_check_mark: | [instagram-user-follow.php](https://github.com/Hasokeyk/instagram/blob/main/examples/user/instagram-user-follow.php) |
| Kullanıcı Takipten Çıkma | :heavy_check_mark: | [instagram-user-follow.php](https://github.com/Hasokeyk/instagram/blob/main/examples/user/instagram-user-follow.php) |
| Kullanıcının Kendisini Takipten Çıkma | :heavy_check_mark: | [instagram-user-follow.php](https://github.com/Hasokeyk/instagram/blob/main/examples/user/instagram-user-follow.php) |
| Kullanıcı Bildirim Listesi Getirme | :heavy_check_mark: | [instagram-user-my-notification.php](https://github.com/Hasokeyk/instagram/blob/main/examples/user/instagram-user-my-notification.php) |
| Kullanıcı Mesaj İsteklerini Getirme | :heavy_check_mark: | [instagram-user-my-pending-inbox.php](https://github.com/Hasokeyk/instagram/blob/main/examples/user/instagram-user-my-pending-inbox.php) |
| Kullanıcı Mesaj Kutusunu Getirme | :heavy_check_mark: | [instagram-user-my-inbox.php](https://github.com/Hasokeyk/instagram/blob/main/examples/user/instagram-user-my-inbox.php) |
| Kullanıcı Takipçilerini Getirme | :heavy_check_mark: | [instagram-user-my-followers.php](https://github.com/Hasokeyk/instagram/blob/main/examples/user/instagram-user-my-followers.php) |
Expand All @@ -177,8 +177,8 @@ paylaşımlarını getirmek için get_user_posts('hasokeyk') yazmanız yeterlidi

| İşlemler | Çalışıyor | Örnek Dosya |
| ------------- | ------------- | ------------- |
| Paylaşım İstatistikleri Getirme | :heavy_check_mark: | [instagram-user-get-posts-statistics.php](https://github.com/Hasokeyk/instagram/blob/main/examples/media/instagram-user-get-posts-statistics.php) |
| Görsel Paylaşma | :x: | [HAZIRLANIYOR](https://github.com/Hasokeyk/instagram/blob/main/examples/media/) |
| Paylaşım İstatistikleri Getirme | :heavy_check_mark: | [instagram-user-get-posts-statistics.php](https://github.com/Hasokeyk/instagram/blob/main/examples/statistics/instagram-user-get-posts-statistics.php) |
| Görsel Paylaşma | :heavy_check_mark: | [instagram-media-share-photo.php](https://github.com/Hasokeyk/instagram/blob/main/examples/media/instagram-media-share-photo.php) |
| Video Paylaşma | :x: | [HAZIRLANIYOR](https://github.com/Hasokeyk/instagram/blob/main/examples/media/) |
| Story Paylaşma | :x: | [HAZIRLANIYOR](https://github.com/Hasokeyk/instagram/blob/main/examples/media/) |
| Carousel Paylaşma | :x: | [HAZIRLANIYOR](https://github.com/Hasokeyk/instagram/blob/main/examples/media/) |
Expand Down
19 changes: 19 additions & 0 deletions examples/media/instagram-media-share-photo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

use instagram\instagram;

require "../../vendor/autoload.php";

$username = 'username';
$password = 'password';

$instagram = new instagram($username,$password);
$instagram->login->login();

if($instagram->login->login_control()){
$image_path = (__DIR__).'/assets/a.jpg';
$check = $instagram->medias->share_photo($image_path,'Test');
print_r($check);
}else{
echo 'Login Fail';
}
4 changes: 4 additions & 0 deletions src/instagram.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

require "instagram_request.php";
require "instagram_login.php";
require "instagram_register.php";
require "instagram_user.php";
require "instagram_statistics.php";
require "instagram_upload.php";
Expand All @@ -15,6 +16,7 @@ class instagram{
public $functions = [];
public $request = null;
public $login = null;
public $register = null;
public $user = null;
public $statistics = null;
public $medias = null;
Expand All @@ -26,6 +28,7 @@ function __construct($username = null, $password = null){
$this->functions = (object) [
'request' => new instagram_request($username, $password, $this->functions),
'login' => new instagram_login($username, $password, $this->functions),
'register' => new instagram_register($username, $password, $this->functions),
'statistics' => new instagram_statistics($username, $password, $this->functions),
'user' => new instagram_user($username, $password, $this->functions),
'upload' => new instagram_upload($username, $password, $this->functions),
Expand All @@ -35,6 +38,7 @@ function __construct($username = null, $password = null){

$this->request = new instagram_request($username, $password, $this->functions);
$this->login = new instagram_login($username, $password, $this->functions);
$this->register = new instagram_register($username, $password, $this->functions);
$this->user = new instagram_user($username, $password, $this->functions);
$this->statistics = new instagram_statistics($username, $password, $this->functions);
$this->upload = new instagram_upload($username, $password, $this->functions);
Expand Down
76 changes: 76 additions & 0 deletions src/instagram_medias.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,4 +279,80 @@ public function share_media_inbox($post_id = null, $username = null){

}

public function share_photo($image_path = null, $desc = 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->_share_photo($upload_id, $desc);
print_r($result);
if($result->status == 'ok'){
return true;
}
}

return false;

}

private function _share_photo($upload_id = null, $desc = null){

$url = 'https://i.instagram.com/api/v1/media/configure/';
$post_data = [
"scene_capture_type" => "",
"timezone_offset" => "10800",
"_csrftoken" => "L3toHeMiinPTPxRkOST8feCLY0gIa61x",
"media_folder" => "Camera",
"source_type" => "4",
"_uid" => "44433622125",
"device_id" => $this->get_device_id(),
"_uuid" => $this->get_guid(),
"creation_logger_session_id" => "cf4fea1e-a304-44d9-af56-62914c9d728e",
"caption" => $desc,
"upload_id" => $upload_id,
"multi_sharing" => "1",
"device" => [
"manufacturer" => "Google",
"model" => "google+Pixel+2",
"android_version" => 22,
"android_release" => "5.1.1",
],
"edits" => [
"crop_original_size" => [
640,
480,
],
"crop_center" => [
0,
-0,
],
"crop_zoom" => 1.3333334,
],
"extra" => [
"source_width" => 640,
"source_height" => 480,
],
];
$post_data = ['signed_body' => 'SIGNATURE.'.json_encode($post_data)];
$json = $this->request($url, 'POST', $post_data);
return json_decode($json['body']);

}
}
94 changes: 94 additions & 0 deletions src/instagram_register.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?php

namespace instagram;

class instagram_register extends instagram_request{

public $username;
public $password;
public $functions;

function __construct($username, $password, $functions = null){
$this->username = $username;
$this->password = $password;
$this->functions = $functions;
}

public function username_check($username = null){

$username = $username??$this->username;

$url = 'https://i.instagram.com/api/v1/users/check_username/';
$post_data = [
'username' => $username,
'_uuid' => $this->get_guid(),
];
$post_data = ['signed_body' => 'SIGNATURE.'.json_encode($post_data)];
$json = $this->request($url, 'POST', $post_data);
if($json['status'] == 'ok'){
$json = json_decode($json['body']);
}
return $json;

}

public function get_steps(){

$url = 'https://i.instagram.com/api/v1/dynamic_onboarding/get_steps/';
$post_data = [
'is_secondary_account_creation' => 'true',
'fb_connected' => 'false',
'seen_steps' => "[]",
'progress_state' => "prefetch",
'fb_installed' => "false",
'is_ci' => "false",
'network_type' => "WIFI-UNKNOWN",
'waterfall_id' => "97d01ad3-6555-49ac-b7f5-69da7f241367",
'tos_accepted' => "false",
'phone_id' => $this->get_phone_id(),
'_uuid' => $this->get_guid(),
'guid' => $this->get_guid(),
'_csrftoken' => $this->get_csrftoken(),
'android_id' => $this->get_device_id(),
];
$post_data = ['signed_body' => 'SIGNATURE.'.json_encode($post_data)];
$json = $this->request($url, 'POST', $post_data);
if($json['status'] == 'ok'){
$json = json_decode($json['body']);
}
return $json;

}

public function register($username = null, $password = null){

$username = $username??$this->username;
$password = $password??$this->password;

$url = 'https://i.instagram.com/api/v1/dynamic_onboarding/get_steps/';
$post_data = [
'is_secondary_account_creation' => 'true',
'fb_connected' => 'false',
'seen_steps' => "[]",
'progress_state' => "prefetch",
'fb_installed' => "false",
'is_ci' => "false",
'network_type' => "WIFI-UNKNOWN",
'waterfall_id' => "97d01ad3-6555-49ac-b7f5-69da7f241367",
'tos_accepted' => "false",
'phone_id' => $this->get_phone_id(),
'_uuid' => $this->get_guid(),
'guid' => $this->get_guid(),
'_csrftoken' => $this->get_csrftoken(),
'android_id' => $this->get_device_id(),
];
$post_data = ['signed_body' => 'SIGNATURE.'.json_encode($post_data)];
$json = $this->request($url, 'POST', $post_data);
if($json['status'] == 'ok'){
$json = json_decode($json['body']);
}
return $json;

}

}
2 changes: 1 addition & 1 deletion src/instagram_upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function rupload_params($upload_id) {
"upload_id" => $upload_id,
"xsharing_user_ids" => "[]",
"image_compression" => json_encode($image_comp),
"original_photo_pdq_hash" => ""//todo add PDQ Hashing algorithm
"original_photo_pdq_hash" => ""
];
return json_encode($data);
}
Expand Down
40 changes: 35 additions & 5 deletions src/instagram_user.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,13 @@ public function get_user_info_by_username($username = null){
public function get_multi_user_friendship_show($user_ids = []){

if($user_ids != null){
$user_ids = implode(',',$user_ids);
$url = 'https://i.instagram.com/api/v1/friendships/show_many/';
$user_ids = implode(',', $user_ids);
$url = 'https://i.instagram.com/api/v1/friendships/show_many/';
$post_data = [
'user_ids' => $user_ids
'user_ids' => $user_ids,
];
$json = $this->request($url,'POST',$post_data);
$json = json_decode($json['body']);
$json = $this->request($url, 'POST', $post_data);
$json = json_decode($json['body']);
return $json;
}

Expand Down Expand Up @@ -592,6 +592,36 @@ public function get_friendships_status_by_username($username = null){

}

public function get_former_usernames($username = null){

$username = $username??$this->username;
$user_id = $this->get_user_id($username);
$url = 'https://i.instagram.com/api/v1/users/'.$user_id.'/former_usernames/';
$json = $this->request($url, 'GET');
$json = json_decode($json['body']);
if(isset($json->status) and $json->status == 'ok'){
return $json;
}
return false;

}

/*
public function get_accounts_with_shared_followers($username = null){
$username = $username??$this->username;
$user_id = $this->get_user_id($username);
$url = 'https://i.instagram.com/api/v1/users/'.$user_id.'/accounts_with_shared_followers/';
$json = $this->request($url, 'POST');
$json = json_decode($json['body']);
if(isset($json->status) and $json->status == 'ok'){
return $json;
}
return false;
}
*/

private function generate_client_context(){
return (round(microtime(true) * 1000) << 22 | random_int(PHP_INT_MIN, PHP_INT_MAX) & 4194303) & PHP_INT_MAX;
}
Expand Down

0 comments on commit fd6ad34

Please sign in to comment.