【发布时间】:2011-08-27 14:22:03
【问题描述】:
作为(OAuthException) (#15) The method you are calling must be called with an app secret signed session 的后续行动,我想知道file_get_contents() 的等价物是什么。我尝试了以下方法,但出现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());
}
我也尝试了System.IO.File.ReadAllText(tokenUrl),但我得到了同样的错误。有什么我可以做的吗?
我什至不确定它是否会起作用,但至少我可以尝试......
【问题讨论】:
-
那个方法已经严重过时了
-
@Tim,该方法声称使用 URL,但仅检查
http:。所以 https 或 ftp 不起作用。 -
您应该使用
List<string>而不是ArrayList。 -
@svick:是的,你对 https 和 ftp 的看法是正确的,实际上我自己添加了这些,因为 Facebook 现在使用 https。如果您知道更智能的实现,请分享:)
标签: c# facebook facebook-c#-sdk inputstream