internal protected virtual string OAuthRequest(string name, string path, IDictionary<string, object> parameters)
{
Contract.Requires(!String.IsNullOrEmpty(name));
var mergedParameters = FacebookUtils.Merge(null, parameters);
path = FacebookUtils.ParseQueryParametersToDictionary(path, mergedParameters);
if (!string.IsNullOrEmpty(path) && path.StartsWith("/", StringComparison.OrdinalIgnoreCase))
{
path = path.Substring(1, path.Length - 1);
}
var requestUrl = GetUrl(name, path, parameters);
var webClient = WebClient;
string responseString = null;
try
{
var resultData = webClient.DownloadData(requestUrl);
if (resultData != null)
{
responseString = Encoding.UTF8.GetString(resultData);
}
}
catch (WebExceptionWrapper ex)
{
responseString = FacebookUtils.GetResponseString(ex);
}
// todo: make sure the url is graph url then only check for graph exception
var graphException = ExceptionFactory.GetGraphException(responseString);
if (graphException != null)
{
throw graphException;
}
return responseString;
}
#endif