C#的file_get_contents等价的(PHP) [英] C# equivalent of file_get_contents (PHP)

查看:289
本文介绍了C#的file_get_contents等价的(PHP)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为后续的(OAuthException)(#15)您所呼叫的方法必须与一个应用程序秘密签署会议我想知道是什么的file_get_contents相当于()被调用。我尝试以下,但我得到了路径中非法字符错误。

As a follow-up to (OAuthException) (#15) The method you are calling must be called with an app secret signed session I want to know what is the equivalent of file_get_contents(). I tried the following but I got illegal characters in path error.

    public ActionResult About()
    {
        var fb = new FacebookWebClient(FacebookWebContext.Current);

        var tokenUrl = "https://graph.facebook.com/oauth/access_token?client_id=" + FacebookWebContext.Current.Settings.AppId + "&client_secret=" + FacebookWebContext.Current.Settings.AppSecret + "&grant_type=client_credentials";
        var objReader = new StreamReader(tokenUrl);
        string sLine = "";
        var arrayList = new ArrayList();

        while (sLine != null)
        {
            sLine = objReader.ReadLine();
            if (sLine != null)
                arrayList.Add(sLine);
        }
        objReader.Close();
        var appToken = arrayList.ToString();

        dynamic result = fb.Post(string.Format("{0}/accounts/test-users", FacebookWebContext.Current.Settings.AppId),
            new { installed = false, permissions = "read_stream", access_token = appToken });
        return Content(result.ToString());
    }



我也试过 System.IO.File.ReadAllText (tokenUrl)和我同样的错误。有什么我可以做什么?

I also tried System.IO.File.ReadAllText(tokenUrl) and I got the same error. Is there anything I can do?

我什至不知道它去上班,但至少我可以试试...

I'm not even sure it's going to work, but at least I can try...

推荐答案

要使用OAuth /的access_token或与OAuth的东西任何方法使用FacebookOAuthClient不FacebookClient或FacebookClient。

To use oauth/access_token or any methods related to oauth stuffs use FacebookOAuthClient not FacebookClient or FacebookClient.

FacebookOAuthClient.GetApplicationAccessToken(..)
FacebookOAuthClient.ExchangeCodeForAccessToken(..)

这篇关于C#的file_get_contents等价的(PHP)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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