function postingImage($conf) { $image = GetPostData($conf['PATH_IMAGE']); $agent = GenerateUserAgent(); $dataUpload = SendRequest(array('url' => 'https://i.instagram.com/api/v1/media/upload/', 'post' => $image, 'agent' => $agent, 'useCookie' => true, 'PATH_COOKIE' => $conf['PATH_COOKIE'])); $response = json_decode($dataUpload[1]); if (empty($response) || $response->status != 'ok') { return $response = array('status' => $response->status, 'data' => $response); } $guid = GenerateGuid(); $device_id = "android-" . $guid; $requestData = '{"device_id":"' . $device_id . '","guid":"' . $guid . '","media_id":"' . $response->media_id . '","caption":"' . trim($conf['title']) . '","device_timestamp":"' . time() . '","source_type":"5","filter_type":"0","extra":"{}","Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"}'; $sig = GenerateSignature($requestData); $new_data = 'signed_body=' . $sig . '.' . urlencode($requestData) . '&ig_sig_key_version=4'; $response = SendRequest(['url' => 'https://i.instagram.com/api/v1/media/configure/', 'post' => $new_data, 'agent' => $agent, 'useCookie' => true, 'PATH_COOKIE' => $conf['PATH_COOKIE']]); $data = json_decode($response[1]); return array('status' => !empty($data) && $data->status == 'ok' ? 200 : 400, 'data' => $data); }
$sig = GenerateSignature($data); $data = 'signed_body=' . $sig . '.' . urlencode($data) . '&ig_sig_key_version=6'; $login = SendRequest('accounts/login/', true, $data, $agent, false); if (strpos($login[1], "Sorry, an error occurred while processing this request.")) { echo "Request failed, there's a chance that this proxy/ip is blocked"; } else { if (empty($login[1])) { echo "Empty response received from the server while trying to login"; } else { // Decode the array that is returned $obj = @json_decode($login[1], true); if (empty($obj)) { echo "Could not decode the response: " . $body; } else { // Post the picture $data = GetPostData($filename); $post = SendRequest('media/upload/', true, $data, $agent, true); if (empty($post[1])) { echo "Empty response received from the server while trying to post the image"; } else { // Decode the response $obj = @json_decode($post[1], true); if (empty($obj)) { echo "Could not decode the response"; } else { $status = $obj['status']; echo var_dump($status); echo "==========================\n\n"; if ($status == 'ok') { // Remove and line breaks from the caption $caption = preg_replace("/\r|\n/", "", $caption);