• 07-08-2021, 16:28:45
    #1
    PHP curl ile çalışan instagram login fonksiyonum vardı ne güzel stabil çalışıyordu. Şuan hiçbirşekilde çalışmıyor. username,password şeklinde doğrulama yapıyordum. Yokmu bunun bi çaresi?

    önceki kod ;

    define('USERNAME', "");
    define('PASSWORD', "");
    define('USERAGENT', "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36");
    define('COOKIE', USERNAME.".txt");
    
    function login_inst() {
    
        @unlink(dirname(__FILE__)."/!instagram/".COOKIE);
    
        $url="https://www.instagram.com/accounts/login/?force_classic_login";
    
        $ch  = curl_init();
    
        $arrSetHeaders = array(
            "User-Agent: USERAGENT",
            'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
            'Accept-Language: en-US,en;q=0.5',
            'Accept-Encoding: deflate, br',
            'Connection: keep-alive',
            'cache-control: max-age=0',
        );
    
        curl_setopt($ch, CURLOPT_HTTPHEADER, $arrSetHeaders);        
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__)."/!instagram/".COOKIE);
        curl_setopt($ch, CURLOPT_COOKIEFILE, dirname(__FILE__)."/!instagram/".COOKIE);
        curl_setopt($ch, CURLOPT_USERAGENT, USERAGENT);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_HEADER, 1);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    
        $page = curl_exec($ch);
        curl_close($ch);  
    
        //var_dump($page);
    
        // try to find the actual login form
        if (!preg_match('/<form method="POST" id="login-form" class="adjacent".*?</form>/is', $page, $form)) {
            die('Failed to find log in form!');
        }
    
        $form = $form[0];
    
        // find the action of the login form
        if (!preg_match('/action="([^"]+)"/i', $form, $action)) {
            die('Failed to find login form url');
        }
    
        $url2 = $action[1]; // this is our new post url
        // find all hidden fields which we need to send with our login, this includes security tokens
        $count = preg_match_all('/<input type="hidden"s*name="([^"]*)"s*value="([^"]*)"/i', $form, $hiddenFields);
    
        $postFields = array();
    
        // turn the hidden fields into an array
        for ($i = 0; $i < $count; ++$i) {
            $postFields[$hiddenFields[1][$i]] = $hiddenFields[2][$i];
        }
    
        // add our login values
        $postFields['username'] = USERNAME;
        $postFields['password'] = PASSWORD;  
    
        $post = '';
    
        // convert to string, this won't work as an array, form will not accept multipart/form-data, only application/x-www-form-urlencoded
        foreach($postFields as $key => $value) {
            $post .= $key . '=' . urlencode($value) . '&';
        }
    
        $post = substr($post, 0, -1);  
    
        preg_match_all('/^Set-Cookie:s*([^;]*)/mi', $page, $matches);
    
        $cookieFileContent = '';
    
        foreach($matches[1] as $item)
        {
            $cookieFileContent .= "$item; ";
        }
    
        $cookieFileContent = rtrim($cookieFileContent, '; ');
        $cookieFileContent = str_replace('sessionid=""; ', '', $cookieFileContent);
    
        $oldContent = file_get_contents(dirname(__FILE__)."/!instagram/".COOKIE);
        $oldContArr = explode("n", $oldContent);
    
        if(count($oldContArr))
        {
            foreach($oldContArr as $k => $line)
            {
                if(strstr($line, '# '))
                {
                    unset($oldContArr[$k]);
                }
            }
    
            $newContent = implode("n", $oldContArr);
            $newContent = trim($newContent, "n");
    
            file_put_contents(
                dirname(__FILE__)."/!instagram/".COOKIE,
                $newContent
            );    
        }
    
        $arrSetHeaders = array(
            'origin: https://www.instagram.com',
            'authority: www.instagram.com',
            'upgrade-insecure-requests: 1',
            'Host: www.instagram.com',
            "User-Agent: USERAGENT",
            'content-type: application/x-www-form-urlencoded',
            'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
            'Accept-Language: en-US,en;q=0.5',
            'Accept-Encoding: deflate, br',
            "Referer: $url",
            "Cookie: $cookieFileContent",
            'Connection: keep-alive',
            'cache-control: max-age=0',
        );
    
        $ch  = curl_init();
        curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__)."/!instagram/".COOKIE);
        curl_setopt($ch, CURLOPT_COOKIEFILE, dirname(__FILE__)."/!instagram/".COOKIE);
        curl_setopt($ch, CURLOPT_USERAGENT, USERAGENT);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_HEADER, 1);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $arrSetHeaders);    
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_REFERER, $url);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $post);  
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    
        sleep(5);
        $page = curl_exec($ch);
    
        /*
        preg_match_all('/^Set-Cookie:s*([^;]*)/mi', $page, $matches);
        COOKIEs = array();
        foreach($matches[1] as $item) {
            parse_str($item, COOKIE1);
            COOKIEs = array_merge(COOKIEs, COOKIE1);
        }
        */
        //var_dump($page);      
        curl_close($ch);  
    
    }
  • 07-08-2021, 16:33:21
    #2
    Guncellemeden sonra fix yedi çalışmaz hocam baştan web login yazmak lazım ücreti ile yardımcı olabilirim
  • 07-08-2021, 17:43:58
    #3
    ReH
    Kimlik doğrulama veya yönetimden onay bekliyor.
    İsterseniz konuma bakabilirsiniz
    https://www.r10.net/script-satisi/25...oid127942.html
  • 11-08-2021, 21:27:06
    #4
    yusuf68700 adlı üyeden alıntı: mesajı görüntüle
    Guncellemeden sonra fix yedi çalışmaz hocam baştan web login yazmak lazım ücreti ile yardımcı olabilirim
    Çok önceden yaptığım giriş sistemi hala sorunsuz çalışıyor.
  • 11-08-2021, 21:49:13
    #5
    WebKadir adlı üyeden alıntı: mesajı görüntüle
    Çok önceden yaptığım giriş sistemi hala sorunsuz çalışıyor.
    bir sürü farklı login yöntemi olduğu için gayet normal değilmi web login ayrı mobil login ayrı hepsi ayrı