Access error
 Регистрация или ->Экспорт данныхПоиск
Войти
Экспорт:
Папки

/var_null/saytostroenie/socialnie-seti/vk/API/_online_
Не экспортировать закрытые директории
Преобразовывать заметки в html
Экспортировать
Открыть директорию для всех Удалить директорию
Применить
 Стили директорииДобавить заметку
code
2015-06-25 00:37:09 Удалить Фон Изображение Импорт из текстового файла Редактировать Копировать в буфер
<?php
header('Content-Type: text/html; utf-8; charset=UTF-8');



require_once(realpath(__DIR__) . '/../../cms/db_in_p.php');

$captcha_sid = $_GET['captcha_sid'];
$cap_val = $_GET['cap_val'];

$cap = false;

//$access_token = "1b62a78c0b9d62fc61569f4c596b933f33cf918af0aea41f274e2301c0f98c17f9bd790ca071f08f2af6e";
//$access_token = "85852bd1074984a5763812b732b632f3c1e0486f9a5f6e10565d340a75149862245c23ee567d7c24ef585";
$access_token = "16d7d1b95354852748eb10bde5db085c9d4a96047dfe4cef1f0548a293ad4b35a470b74975384bbcf2fdd";

$gid = "83695024";

/*
        $link = "http://./";        
        $urlImage = 'http://cs540103.vk.me/c624821/v624821443/13a35/tVLSSnIeks0.jpg';        
        $msg = "test";
        
        
        fnc_post_fnc($access_token, $gid, $msg, $link, $urlImage, $captcha_sid, $cap_val);

*/




//So

$data_mas = getDataPost();

if($data_mas['post'] > 0 && $data_mas['msg'] != "")
{
    //Go    
    
    $msg = $data_mas['msg'];
    $link = $data_mas['link'];
    $urlImage = $data_mas['urlImage'];    
    
    echo "msg:<br>";
    echo "<div style='border:1px solid #808080'>";
    
        echo $msg;
    
    echo "</div>";
    
    echo "link:<br>";
    echo "<div style='border:1px solid #808080'>";
    
        echo $link;
    
    echo "</div>";

    echo "urlImage:<br>";
    echo "<div style='border:1px solid #808080'>";
    
        echo $urlImage;
    
    echo "</div>";    

    echo "Posting:<br>";
    
    fnc_post_fnc($access_token, $gid, $msg, $link, $urlImage, $captcha_sid, $cap_val);
    
}

endPost($data_mas['id']);

setOnline($access_token);

//$rnd = rand(0, 10000000);

/*
$status_text_mas = array();

$status_text_mas[] = "";
$status_text_mas[] = "";
$status_text_mas[] = "";
$status_text_mas[] = "";
$status_text_mas[] = "";
$status_text_mas[] = "";
$status_text_mas[] = "";
$status_text_mas[] = "";
$status_text_mas[] = "";
$status_text_mas[] = "";
$status_text_mas[] = "";
$status_text_mas[] = " ";

shuffle($status_text_mas);

$status_text_set = implode("", $status_text_mas);

$status_text_set = date("Y-m-d");
*/

$city_id=26063; // id
$data_file="http://export.yandex.ru/weather-ng/forecasts/$city_id.xml"; // xml

$xml = simplexml_load_file($data_file); // xml

$temp = $xml->fact->temperature + 0;
$type = $xml->fact->weather_type;

// , "+"
if($temp > 0)
    {
        $temp = '+' . $temp;
    }

    $status_text_set = date("Y-m-d") . " " . date("H") . "";    
    
    if($type != "")
        $status_text_set = date("Y-m-d") . " " . date("H") . "" . " . " . $temp . " " . $type;    

    setStatus($status_text_set, $access_token);

function endPost($id)
{
    global $text;

    if($id > 0)
    {
        if(!$cap)
        {    
            //end
        
            $query = "update strct_in7p7datas set post_in_vk=1 where strct_in7p7data_id=" . mysql_real_escape_string($id);
            $text->my_sql_query = $query;
            $text->my_sql_execute();

        
        }    
    }
}

function getDataPost()
{
    global $text;
    
    $data_mas = array();
    
    $msg = "";
    $link = "";
    $urlImage = "";
    
    
    
    $text->my_sql_query='select * from strct_in7p7datas where post_in_vk=0 order by strct_in7p7data_datetime_datetime limit 0,1';
    $text->my_sql_execute();            
    while ($res = mysql_fetch_object($text->my_sql_res))
    {
        $obj_data_all_mas[] = (array) $res;        
        
    }    
    
        echo "<pre>";
        
        print_r($obj_data_all_mas[0]);
        
        echo "</pre>";
        
        $lock = true;    
    
    
    if(count($obj_data_all_mas) == 1)
    {

        
        $select = 'select strct_in7p7menu_lock_int as this_lock from strct_in7p7menus where strct_in7p7menu_id = ' . mysql_real_escape_string($obj_data_all_mas[0]['strct_in7p7data_parent7id_int']);
            
        $text->my_sql_query = $select;
        $text->my_sql_execute();            
        $res = mysql_fetch_object($text->my_sql_res);
        
        if($res->this_lock != 1)
            $lock = false;
            
        $data_mas['id'] = $obj_data_all_mas[0]['strct_in7p7data_id'];
        
        $fnc = $obj_data_all_mas[0]['strct_in7p7data_fnc_varchar'];
        
        $fnc_mas = explode(" ", $fnc);
        
        $open = false;
        $look = true;
        
        for($n = 0; $n < count($fnc_mas); $n++)
        {    
            if($fnc_mas[$n] == "open")
                $open = true;
        
            if($fnc_mas[$n] == "unlook")
                $look = false;                
        }
        
        if($look && !$lock)
        {                    
            $data_mas['post'] = 1;
            
            $data_mas['urlImage'] = $obj_data_all_mas[0]['strct_in7p7data_img7href_varchar'];
            
            echo "type=" . $obj_data_all_mas[0]['strct_in7p7data_type_varchar'] . "<br>";
            
            if($obj_data_all_mas[0]['strct_in7p7data_type_varchar'] == "text")
            {
                
                $title = "";
                $type = "";
            
                if($obj_data_all_mas[0]['strct_in7p7data_sign_varchar'] != "")        
                    $type = "" . $obj_data_all_mas[0]['strct_in7p7data_sign_varchar'] . " ";
                else
                    $type = " ";            
            
                $title .= $type . "'" . iconv('cp1251', 'utf-8', $obj_data_all_mas[0]['strct_in7p7data_name7rus_varchar']) . "'";
                                
                $title .= " " . getPathMenuById($obj_data_all_mas[0]['strct_in7p7data_parent7id_int'], "");    


                if($open)
                {
                    $text->my_sql_query='select strct_in7p7type7text_text_text as text from strct_in7p7type7texts
        where strct_in7p7type7text_id = ' . mysql_real_escape_string($obj_data_all_mas[0]['strct_in7p7data_obj7id_int']);
                    $text->my_sql_execute();            
                    $res = mysql_fetch_object($text->my_sql_res);
                    
                    $text_text = iconv('cp1251', 'utf-8', $res->text);
                    
                    if($text_text != "")
                    {
                        $text_text = substr($text_text, 0, 200);
                        
                        $title .= ": " .$text_text;
                    }

                }                    
            
                $title = urlencode(htmlentities($title));
            
                echo $title . "<br>";
            
                $data_mas['msg'] = $title;                
                
                $data_mas['link'] = urlencode(htmlentities("http://xn--80addj8aakhjc.xn--p1ai/" . getPathEngMenuById($obj_data_all_mas[0]['strct_in7p7data_parent7id_int'], "")));
            }
            
            if($obj_data_all_mas[0]['strct_in7p7data_type_varchar'] == "comment")
            {
                $type = " ";
                
                $title .= " " . getPathMenuById($obj_data_all_mas[0]['strct_in7p7data_parent7id_int'], "");
                
                $text->my_sql_query='select strct_in7p7type7comment_text_text as text from strct_in7p7type7comments
        where strct_in7p7type7comment_id = ' . mysql_real_escape_string($obj_data_all_mas[0]['strct_in7p7data_obj7id_int']);
                    $text->my_sql_execute();            
                    $res = mysql_fetch_object($text->my_sql_res);
                    
                    $text_text = iconv('cp1251', 'utf-8', $res->text);
                    
                    if($text_text != "")
                    {
                        $text_text = substr($text_text, 0, 200);
                        
                        $title .= ": " .$text_text;
                    }    

                $title = urlencode(htmlentities($title));
            
                echo $title . "<br>";
            
                $data_mas['msg'] = $title;                
                
                $data_mas['link'] = urlencode(htmlentities("http://xn--80addj8aakhjc.xn--p1ai/" . getPathEngMenuById($obj_data_all_mas[0]['strct_in7p7data_parent7id_int'], "")));                    
            
            }
            
            
            if($obj_data_all_mas[0]['strct_in7p7data_type_varchar'] == "href")
            {
                $type = " ";
                
                $text->my_sql_query='select strct_in7p7type7href_id as id, strct_in7p7type7href_href_text as text from strct_in7p7type7hrefs
    where strct_in7p7type7href_id = ' . mysql_real_escape_string($obj_data_all_mas[0]['strct_in7p7data_obj7id_int']);
                $text->my_sql_execute();            
                $res = mysql_fetch_object($text->my_sql_res);                
                
                $title .= $type . "'" . iconv('cp1251', 'utf-8', $res->text) . "'";
                
                $title .= " " . getPathMenuById($obj_data_all_mas[0]['strct_in7p7data_parent7id_int'], "");    
                
                $title = urlencode(htmlentities($title));
            
                echo $title . "<br>";
            
                $data_mas['msg'] = $title;                    

                $data_mas['link'] = urlencode(htmlentities($obj_data_all_mas[0]['strct_in7p7data_name7rus_varchar']));                
            
            
            }
            
        }
        else
            echo "unlook!<br>";    
        

    }
    
    return $data_mas;

}

function capcha($con_mas)
{
    global $cap;

    if(is_array($con_mas['error']))
    {
        echo "<pre>";

        print_r($con_mas);

        echo "</pre>";        
    
        if($con_mas['error']['error_code'] == 14)
        {
            //Captcha needed
            
            echo "Captcha needed!!!<br>";
            echo "error_cap<br>";
            
            echo "<img src='" . $con_mas['error']['captcha_img'] . "'/>";
            echo "<input type='text' value='' id='" . $con_mas['error']['captcha_sid'] . "'><br>";
            echo "<span class='send_cap' style='border:1px solid red; cursor:pointer' captcha_sid='" . $con_mas['error']['captcha_sid'] . "'>send cap</span><br>";
    
            $cap = true;
    
        }    
    
    }
}
        
function fnc_post_fnc($access_token, $gid, $msg, $link, $urlImage, $captcha_sid, $cap_val)
{        
    if($urlImage != "")
    {

        $args = array();
        $args['gid'] = $gid; //fondovik
        $args['access_token'] = $access_token;
        
        if($captcha_sid != "")
        {    
            $args['captcha_sid'] = $captcha_sid;
            $args['captcha_key'] = $cap_val;
            
        }        
        
        $mas_response = photos_getWallUploadServer($args);
        
        echo "<pre>";

        print_r($mas_response);

        echo "</pre>";    
        
        $upload_url = $mas_response['response']['upload_url'];
        
        if($upload_url != "")
        {
            $file_name = "tmp.jpg";            
            file_put_contents($file_name, file_get_contents($urlImage));        
        
            $mas_response = UploadServer($upload_url, $file_name);
        }
        
        echo "<pre>";

        print_r($mas_response);

        echo "</pre>";    

        $args = array();
        $args['gid'] = $gid; //fondovik
        $args['access_token'] = $access_token;
        $args['photo'] = $mas_response['photo'];
        $args['server'] = $mas_response['server'];
        $args['hash'] = $mas_response['hash'];    

        if($captcha_sid != "")
        {    
            $args['captcha_sid'] = $captcha_sid;
            $args['captcha_key'] = $cap_val;
            
        }            
        
        $photos_saveWallPhoto_response = photos_saveWallPhoto($args);
        
        echo "<pre>";

        print_r($photos_saveWallPhoto_response);

        echo "</pre>";                
            
        $photo_id = $photos_saveWallPhoto_response['response'][0]['id'];

    }
    
        $args = array();
        $args['owner_id'] = "-" . $gid; //fondovik
        $args['access_token'] = $access_token;
        $args['from_group'] = 1;
        $args['signed'] = 0;
        $args['message'] = $msg;
        
        if($captcha_sid != "")
        {    
            $args['captcha_sid'] = $captcha_sid;
            $args['captcha_key'] = $cap_val;
            
        }            
        
        if($photo_id != "" && $link != "")
        {
            $args['attachments'] = $photo_id . ',' . $link;        
        }
        elseif($photo_id != "")
        {
            $args['attachments'] = $photo_id;
        }
        elseif($link != "")
        {
            $args['attachments'] = $link;
        }
            
        $wall_post_response = wall_post($args);    

        echo "<pre>";

        print_r($wall_post_response);

        echo "</pre>";    
        
}        

function setStatus($status_text, $access_token)
{
    $return_mas = array();
    
    $postvars = "text=" . $status_text . "&access_token=" . $access_token;
    
    //echo "postvars=" . $postvars . "<br>";
    
    $ch = curl_init();    
    curl_setopt($ch, CURLOPT_URL, "https://api.vk.com/method/status.set");
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
    curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false );
    curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0 );
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postvars);
    $con = curl_exec($ch);    
    curl_close($ch);

    $return_mas = json_decode($con, true);

    capcha($return_mas);    
    
    return $return_mas;    

}

function setOnline($access_token)
{
    $return_mas = array();
    
    $postvars = "access_token=" . $access_token;
    
    //echo "postvars=" . $postvars . "<br>";
    
    $ch = curl_init();    
    curl_setopt($ch, CURLOPT_URL, "https://api.vk.com/method/account.setOnline");
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
    curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false );
    curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0 );
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postvars);
    $con = curl_exec($ch);    
    curl_close($ch);

    $return_mas = json_decode($con, true);

    capcha($return_mas);    
    
    return $return_mas;
}    

function photos_saveWallPhoto($args)
{
    $return_mas = array();
    
    $postvars = "group_id=" . $args['group_id'] . getArgsStr($args, "group_id");
    
    //echo "postvars=" . $postvars . "<br>";
    
    $ch = curl_init();    
    curl_setopt($ch, CURLOPT_URL, "https://api.vk.com/method/photos.saveWallPhoto");
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
    curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false );
    curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0 );
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postvars);
    $con = curl_exec($ch);    
    curl_close($ch);

    $return_mas = json_decode($con, true);

    capcha($return_mas);    
    
    return $return_mas;
}        
        
function UploadServer($upload_url, $file_name)
{
    $return_mas = array();
    
    $post_params = array(
    "file1" => "@".dirname(__FILE__)."/" . $file_name
    );

    $ch = curl_init();    
    curl_setopt($ch, CURLOPT_URL, $upload_url);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post_params);
    $con = curl_exec($ch);    
    curl_close($ch);

    $return_mas = json_decode($con, true);    
    
    capcha($return_mas);
    
    return $return_mas;
}        

function photos_getWallUploadServer($args)
{
    $return_mas = array();
    
    $postvars = "gid=" . $args['gid'] . getArgsStr($args, "gid");//35410051
    
    //echo "postvars=" . $postvars . "<br>";
    
    $ch = curl_init();    
    curl_setopt($ch, CURLOPT_URL, "https://api.vk.com/method/photos.getWallUploadServer");
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
    curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false );
    curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0 );
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postvars);
    $con = curl_exec($ch);    
    curl_close($ch);

    $return_mas = json_decode($con, true);    
    
    capcha($return_mas);
    
    return $return_mas;
}        
        
function wall_post($args)
{
    $return_mas = array();
    
    $postvars = "owner_id=" . $args['owner_id'] . getArgsStr($args, "owner_id");//-35410051
    
    //echo "postvars=" . $postvars . "<br>";
    
    $ch = curl_init();    
    curl_setopt($ch, CURLOPT_URL, "https://api.vk.com/method/wall.post");
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
    curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false );
    curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0 );
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postvars);
    $con = curl_exec($ch);    
    curl_close($ch);

    $return_mas = json_decode($con, true);    
    
    capcha($return_mas);
    
    return $return_mas;
}

function getArgsStr($args, $exc)
{
    $args_str = "";
    
    $keys_args = array_keys($args);
    
    for($k = 0; $k < count($keys_args); $k++)
    {
        if($keys_args[$k] != $exc)
            $args_str .= "&" . $keys_args[$k] . "=" . $args[$keys_args[$k]];
    }
    
    return $args_str;
}


?>

Получение толкена) ftp://5.101.157.19/xn--80addj8aakhjc.xn--p1ai/public_html/vk/post/ http://xn--80addj8aakhjc.xn--p1ai/vk/post/vp_post_in_vk.php/vp_post_in_vk.php

Участвуй в наполнении сайта, создай свое дерево знаний. Регистрация

@include_encode 2015