如何检索用户的新闻提要列表(VK.com)? [英] How to retrieve user's newsfeed list (VK.com)?

查看:212
本文介绍了如何检索用户的新闻提要列表(VK.com)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下php代码:

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;

尝试上述代码时出现错误.我已成功完成身份验证并将用户配置文件信息存储在mysql表中.我注意到当我在应用程序">设置"中看到"Api.Console"权限时,看到了访问墙"权限.但是在我用来检索数据的应用程序中,我没有看到此权限.

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

错误代码:7

文档描述不充分.甚至我无法确定哪个字段是必填字段还是可选字段.带有过滤器其他"的wall.get与newsfeed.get有什么区别?

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 ?

登录代码:

$AuthURL = $vk->getAuthorizeURL('notify,friends,photos,audio,video,docs,notes,pages,status,offers,questions,wall,groups,notifications,stats,ads,offline', $redirect_uri);

验证码:

$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. 首先,您必须注册应用程序: vk.com/editapp?act=create

然后您需要获取授权代码.为此,请点击链接: oauth.vk.com/authorize?client_id={APP_ID} & scope = {API_SETTINGS} 其中 {APP_ID} -您的应用程序ID(请参阅应用程序设置"页上的), {API_SETTINGS} -您的应用请求的访问权限(通过逗号).如果需要无限令牌,请使用键"offline".对于新闻源,请使用键"墙壁,朋友,离线". 打开页面.在URL 之后 #code =

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=

稍后您需要获取访问令牌.转到链接: https://oauth.vk.com/access_token?client_id= {APP_ID} & client_secret = {API_SECRET} & code = {CODE} 其中 {API_SECRET} -秘密应用程序密钥(请参阅应用程序设置页), {CODE} -在步骤2中复制的代码. 复制access_token .

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.

要获取新闻源数据请求链接,请执行以下操作: https://api.vk.com/method/newsfeed.get.xml? access_token = {ACCESS_TOKEN} 其中 {ACCESS_TOKEN} -步骤3中的令牌.

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.

注意:使用此操作时请使用HTTPs

NOTE: USE HTTPS WHEN USING THIS ACTIONS

这篇关于如何检索用户的新闻提要列表(VK.com)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆