Отправка граффити вконтакте

Discussion in 'PHP' started by egych, 3 Nov 2009.

  1. egych

    egych New Member

    Joined:
    2 Nov 2009
    Messages:
    2
    Likes Received:
    0
    Reputations:
    0
    Помогите с отправкой граффити в контакт. Приведенный ниже код не работает...
    PHP:
        function authGraffity($login$pass) { 
            
    $login urlencode($login); 
            
    $pass urlencode($pass); 

            
    $ch curl_init('http://login.vk.com/?act=login'); 
            
    curl_setopt($chCURLOPT_RETURNTRANSFER1); 
            
    curl_setopt($chCURLOPT_USERAGENT'Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3'); 
            
    curl_setopt($chCURLOPT_TIMEOUT10); 
            
    curl_setopt($chCURLOPT_REFERER'http://vkontakte.ru/'); 
            
    curl_setopt($chCURLOPT_POST1); 
            
    curl_setopt($chCURLOPT_FOLLOWLOCATION1); 
            
    curl_setopt($chCURLOPT_POSTFIELDS"email=$login&pass=$pass&expire=&vk="); 
            
    $res curl_exec($ch); 

            if(
    preg_match('#name=\'s\' id=\'s\' value=\'(.*)\'#'$res$s)) 
                return 
    $s[1]; 
            else 
                return 
    false
        }
        function 
    sendGraffity($id$gid$filename$cook) {
            
    $url 'http://vkontakte.ru/graffiti.php?to_id='.$id.'&group_id='.$gid;
            
    $url_info=parse_url($url);  
            
    $port = isset($url_info['port']) ? $url_info['port'] : 80;  
            
    $socket fsockopen($url_info['host'], $port$errno$errstr30);
            
            
    $pngSig md5(substr(base64_encode(file_get_contents($_SERVER['DOCUMENT_ROOT'].'/vkgraff'.$filename)), 01024));

            
            
    $load2 '----OLEG-ANDREEV-PAVEL-DUROV-GRAFFITI-POST \r\n' .
                     
    'Content-Disposition: form-data; name="Signature"\r\n\r\n' .
                     
    'thefucking32bits.idontknowwhatwr\r\n' .
                     
    '----OLEG-ANDREEV-PAVEL-DUROV-GRAFFITI-POST\r\n' .
                     
    'Content-Disposition: form-data; name="Filedata"; filename="graffiti.png" \r\n' .
                     
    'Content-Type: image/png \r\n\r\n';

            
    $load1 'POST http://vkontakte.ru/graffiti.php?to_id='.$id.'&group_id='.$gid.' HTTP/1.1 \r\n' .
                     
    'Host: vkontakte.ru \r\n' .
                     
    'User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1;) Firefox/2.0.0.3 \r\n' .
                     
    'Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,/*;q=0.5 \r\n' .
                     
    'Accept-Language: ru,en-us;q=0.7,en;q=0.3 \n' .
                     
    'Accept-Encoding: gzip,deflate \n' .
                     
    'Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.7 \r\n' .
                     
    'Keep-Alive: 300 \n' .
                     
    'Connection: keep-alive \n' .
                     
    'Cookie: remixlang=0; remixclosed_tabs=0; remixchk=5; remixid='.$cook.'\n' .
                     
    'Referer: http://vkontakte.ru/swf/Graffiti.swf?12 \r\n' .
                     
    'Content-type: multipart/form-data; boundary=--OLEG-ANDREEV-PAVEL-DUROV-GRAFFITI-POST \r\n' .
                     
    'Content-Length: ';
            
    $tmp file_get_contents($_SERVER['DOCUMENT_ROOT'].'/vkgraff'.$filename);
            
    $value $load1 strval(strlen($tmp)+strlen($load2)+43).'\r\n\r\n'.str_replace($load2'thefucking32bits.idontknowwhatwr'$pngSig);

            
    $postValue $value $tmp '\r\n----OLEG-ANDREEV-PAVEL-DUROV-GRAFFITI-POST \r\n';

            
    fputs($socket$postValue);  
            while(!
    feof($socket) or ($eoheader==true)) {  
                    if(
    $header fgets($socket1024)) {  
                        if (
    $header == "\r\n") {  
                            
    $eoheader true;  
                            break;  
                        } else {  
                            
    $header trim($header);  
                        }  
                        
    $format=0;  
                        if(
    $format == 1) {  
                        
    $key array_shift(explode(':',$header));  
                            if(
    $key == $header) {  
                                
    $headers[] = $header;  
                            } else {  
                                
    $headers[$key]=substr($header,strlen($key)+2);  
                            }  
                        unset(
    $key);  
                        } else {  
                            
    $headers[] = $header;  
                        }  
                    }  
                }  
            return 
    $headers;  
        }
        
        
    $cook authGraffity('qwerty@qwerty.ru''qwerty');
        
    sendGraffity('123456''0''/graffity.png'$cook);
        
    header("Location: http://vkontakte.ru/graffiti.php?act=last");
     
    #1 egych, 3 Nov 2009
    Last edited: 3 Nov 2009
  2. Deathdreams

    Deathdreams Elder - Старейшина

    Joined:
    8 Nov 2008
    Messages:
    342
    Likes Received:
    116
    Reputations:
    5
    Что возращает скрипт?

    P.S. каринка должна храниться в папке vkgraff, согласно твоему скрипту.
     
  3. egych

    egych New Member

    Joined:
    2 Nov 2009
    Messages:
    2
    Likes Received:
    0
    Reputations:
    0
    ну я как бы это понимаю, она там и лежит) скрипт перенаправляет на страницу vkontakte.ru/graffiti.php?act=draw&to_id=123456, то есть на страницу с редактором граффити, предлагая нарисовать новое...