作爲(OAuthException) (#15) The method you are calling must be called with an app secret signed session的後續操作,我想知道file_get_contents()的等價物是什麼。我嘗試了以下,但我得到illegal characters in path
錯誤。C#等價於file_get_contents(PHP)
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)
和我得到了同樣的錯誤。有什麼我可以做的嗎?
我什至不知道它去上班,但至少我可以試試...
http://www.devprise.com/2006/07/14/c-method-to-mimic-php-file_get_contents/ – 2011-05-17 21:29:09
該方法在很大程度上過時 – Bas 2011-05-17 21:32:07
@Tim,該方法宣稱與網址,但只檢查'http:'。所以HTTPS或FTP不起作用。 – svick 2011-05-17 22:56:02