C # equivalent to file_get_contents (PHP)

As a continuation (OAuthException) (# 15) The method you call must be invoked with a secret signed application session . I want to know what the equivalent of file_get_contents () is. I tried the following but got an error illegal characters in path.

    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());
    }

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 if this will work, but at least I can try ...

+2
source share
2 answers

To use oauth / access_token or any methods associated with oauth files, use FacebookOAuthClient, not FacebookClient or FacebookClient.

FacebookOAuthClient.GetApplicationAccessToken(..)
FacebookOAuthClient.ExchangeCodeForAccessToken(..)
+1
source

WebClient.DownloadString URL-. WebClient .

, , :

string test;
string[] lines = test.Split('\n');
+4

All Articles