vk api polls.getById访问被拒绝

时间:2019-01-02 20:18:11

标签: php api vk

https://vk.com/dev/polls.getById?params[is_board]=0&params[poll_id]=317438729&params[extended]=0&params[friends_count]=3&params[name_case]=nom&params[v]=5.92 这个数据-好吧。

使用https://github.com/VKCOM/vk-php-sdk

    $session = \Yii::$app->session;
    $session->open();




    $poll_id = 317356228;
    $client_id =    345435534;
    $owner_id  = 12403939;
    $redirect_uri =  'http://ovz1.siteheltru.10301.vps.myjino.ru/';

    $vk_access_token = $session->get('vk_access_token');



    if (isset($_GET['code'])){
        $oauth = new VKOAuth();
        $client_id = 345435534;
        $client_secret = 'abbfrdtret434e53';

        $code = $_GET['code'];

        $response = $oauth->getAccessToken($client_id, $client_secret, $redirect_uri, $code);
        $vk_access_token = $response['access_token'];
        $session->set('vk_access_token',$vk_access_token);

    }


    if ($vk_access_token === null){

        $oauth = new VKOAuth();


        $display = VKOAuthDisplay::PAGE;
        $scope = array(VKOAuthUserScope::FRIENDS,VKOAuthUserScope::WALL, VKOAuthUserScope::GROUPS,VKOAuthUserScope::OFFLINE,VKOAuthUserScope::EMAIL,VKOAuthUserScope::STATS);
        $state = 'secret_state_code';

        $browser_url = $oauth->getAuthorizeUrl(VKOAuthResponseType::CODE, $client_id, $redirect_uri, $display, $scope, $state);



        $session->close();
        ex($browser_url);
        header("Location: $browser_url");
        exit;



    }


    if ($vk_access_token !== null){
        $access_token = $vk_access_token;

        $vk = new VKApiClient();

        $response = $vk->polls()->getById($access_token, array('poll_id'  =>317438729,'owner_id'=>12403939));
        // this VK\Exceptions\Api\VKApiAccessException -> Access denied: no access to call this method




    }

    $session->close();

    return $this->render('index');

结果:  访问被拒绝:无法访问此方法-wtf?

范围-朋友,墙,组,离线,电子邮件,统计信息

但是:

 $response = $vk->friends()->getOnline($access_token, array('user_id'  => 12403939));

结果:

array(14) {
  [0]=>
  int(3504361)
  [1]=>
  int(7205796)
  [2]=>
  int(15443605)
  [3]=>
  int(16290123)
  [4]=>
  int(25067207)
  [5]=>
  int(26335466)
  [6]=>
  int(32867212)
  [7]=>
  int(41490089)
  [8]=>
  int(42698736)
  [9]=>
  int(53279958)
  [10]=>
  int(56613282)
  [11]=>
  int(102569344)
  [12]=>
  int(132793133)
  [13]=>
  int(141786214)
}

0 个答案:

没有答案