问题
I am using following php code :
$vk = new VK($app_id, $api_secret);
$user_wall = $vk->api('newsfeed.get', array(
//'owner_id' => $o->profile_uid,
'count' => 100,
'filters' => 'post,photo,wall_photo,friend',
'access_token' => $o->profile_token
));
echo '<pre>';
print_r($user_wall);
exit;
I am getting error when trying above code. I have successfully completed auth and stored user profile info in mysql table. I notice that when I see Api.Console permission in App> Setting, I see Access the Wall permission. But in application I used to retrieve data, I do not see this permission.
Error description : Permission to perform this action is denied
Error code : 7
The documentation is poorly described. Even which field is required or optional I can not determine. And what is difference between wall.get with filter "others" vs newsfeed.get ?
LOGIN CODE:
$AuthURL = $vk->getAuthorizeURL('notify,friends,photos,audio,video,docs,notes,pages,status,offers,questions,wall,groups,notifications,stats,ads,offline', $redirect_uri);
AUTH CODE:
$vk_code = $_REQUEST['code'];
$vk = new VK($app_id, $app_secret);
$access_token = $vk->getAccessToken($vk_code, $redirect_uri);
$uid = $access_token['user_id'];
$token = $access_token['access_token'];
$user_info = $vk->api('users.get', array(
'user_ids' => $uid,
'fields' => 'nickname, screen_name, sex, bdate (birthdate), city, country, timezone, photo, photo_medium, photo_big, has_mobile, contacts, education, online, counters, relation, last_seen, activity, can_write_private_message, can_see_all_posts, can_post, universities, counters'
));
回答1:
First you must register application: vk.com/editapp?act=create
Then you need get authorize code. To do this follow link: oauth.vk.com/authorize?client_id={APP_ID}&scope={API_SETTINGS} Where {APP_ID} — your application id (see on app settings page), {API_SETTINGS} — access rights requested by your app (through comma). If need infinite token use key "offline". For newsfeed need use key "wall,friends,offline". Opens page. Copy string in URL AFTER #code=
Later you need get access token. Go to link: https://oauth.vk.com/access_token?client_id={APP_ID}&client_secret={API_SECRET}&code={CODE} Where {API_SECRET} — secret application key (see on app settings page), {CODE} — code that was copied in step 2. Copy access_token.
To get newsfeed data request link: https://api.vk.com/method/newsfeed.get.xml?access_token={ACCESS_TOKEN} Where {ACCESS_TOKEN} — token that was in step 3.
NOTE: USE HTTPS WHEN USING THIS ACTIONS
回答2:
You need the following rights to call this method: wall and friends. (Read more on rights)
You must generate authorization with wall and friends...
https://oauth.vk.com/authorize?client_id=APP_ID&scope=wall,friends,offline
Just replace APP_ID with your appilication and then get your token
来源:https://stackoverflow.com/questions/18802173/how-to-retrieve-users-newsfeed-list-vk-com