请求此资源需要访问令牌 FQL 问题

发布于 2025-01-07 20:09:30 字数 1369 浏览 0 评论 0原文

我有一个执行查询的命令行应用程序。这是代码。

问题是它收到“abc...|xyz...”形式的访问令牌。有 没有会话部分。但返回的令牌对于执行我的查询是无用的 选择我的页面的见解。帮助 !!

       const string permissions  = "manage_pages,read_insights,offline_access";

        dynamic oauthClient = new FacebookOAuthClient() ;
        oauthClient.AppId = username ;
        oauthClient.AppSecret = password ;

        dynamic parameters = new ExpandoObject() ;
        parameters.scope = permissions ;
        parameters.response_type = "token" ;
        // parameters.grant_type = "client_credentials" ;

        dynamic result = oauthClient.GetApplicationAccessToken(parameters);
        string token =  result.access_token ;  
       // token comes back as "abc...|xyz..." 

        var fb = new FacebookClient(token); 
        string query = " select metric, value  " + 
                       " from insights  " + 
                       " where object_id = MY_PAGE and " + 
                       "       metric in ( 'page_impressions' , 'page_stories') and " + 
                       "       end_time >= end_time_date('2012-02-21') and " + 
                       "       end_time <= end_time_date('2012-02-11') and " + 
                       "       period = period('day') " ; 

        dynamic result2 = fb.Query(query) ;  // Exception generated on this line.

        return result2 ;

有什么想法吗?

I have a command line application which executes a query. Here is the code.

Problem is that it receives an access token of the form "abc...|xyz...". There is
no session portion. But the token returned is useless for executing my query to
select insights for a page of mine. Help !!

       const string permissions  = "manage_pages,read_insights,offline_access";

        dynamic oauthClient = new FacebookOAuthClient() ;
        oauthClient.AppId = username ;
        oauthClient.AppSecret = password ;

        dynamic parameters = new ExpandoObject() ;
        parameters.scope = permissions ;
        parameters.response_type = "token" ;
        // parameters.grant_type = "client_credentials" ;

        dynamic result = oauthClient.GetApplicationAccessToken(parameters);
        string token =  result.access_token ;  
       // token comes back as "abc...|xyz..." 

        var fb = new FacebookClient(token); 
        string query = " select metric, value  " + 
                       " from insights  " + 
                       " where object_id = MY_PAGE and " + 
                       "       metric in ( 'page_impressions' , 'page_stories') and " + 
                       "       end_time >= end_time_date('2012-02-21') and " + 
                       "       end_time <= end_time_date('2012-02-11') and " + 
                       "       period = period('day') " ; 

        dynamic result2 = fb.Query(query) ;  // Exception generated on this line.

        return result2 ;

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

黎夕旧梦 2025-01-14 20:09:30

您收到的错误来自 Facebook,它只是说您没有有效的令牌来发出请求。您必须使用 OAuth 请求用户访问令牌。获得有效的访问令牌后,您可以使用以下代码提出请求:

var fb = new FacebookClient("valid_user_access_token"); 
string query = "YOUR FQL QUERY HERE";
dynamic result = fb.Query(query);

要了解如何获取有效的访问令牌,请阅读此处的 Facebook 文档:https://developers.facebook.com/docs/authentication/

The error you are getting is from Facebook and it is simply saying you don't have a valid token to make the request. You must request a user access token using OAuth. After you have a valid access token you can make your request with the following code:

var fb = new FacebookClient("valid_user_access_token"); 
string query = "YOUR FQL QUERY HERE";
dynamic result = fb.Query(query);

To learn how to get a valid access token read the Facebook documentation here: https://developers.facebook.com/docs/authentication/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文