Skip to content

Instantly share code, notes, and snippets.

@malkitsingh
Last active August 29, 2015 14:10
Show Gist options
  • Save malkitsingh/dbcf1479679d2f958529 to your computer and use it in GitHub Desktop.
Save malkitsingh/dbcf1479679d2f958529 to your computer and use it in GitHub Desktop.
to allow cross site service call for web api
<system.webServer>
<httpProtocol>
<customHeaders>
<!-- Adding the following custom HttpHeader will help prevent CORS from stopping the Request-->
<add name="Access-Control-Allow-Origin" value="*" />
</customHeaders>
</httpProtocol>
</system.webServer>
public StringResult fdfriendstestservice()
{
//WebClient wc = new WebClient();
//string NoochAppAccessToken = Utility.GetValueFromConfig("NoochFBAppAccessToken");// CAAC0VZAIiwsEBAEceki7EWz7UryKqsrtZC9cP0KDptv9MlZCCHdL0rU6nXpYJGfL6XoCDRYntjGN1NEiNypIYyeZBBkPlSiFwUeTZBXDqRXU1wiF5ggqrHLUxPANyAz8RGqZCkZAwxa3f4eqjjuL0EipDeOjxNQatTWU94inMjYkNwwOxomyYZBy8KoZCYxNYtGyiyeZBWT6ucTnbcFLBVEG7K
//string urlString = "https://graph.facebook.com/v2.2/" + "1212400310" +
// "/friends/?key=value&access_token=" + NoochAppAccessToken;
//string fbGraphResultString = wc.DownloadString(urlString);
//FBResponseClass fbGraphResults = JsonConvert.DeserializeObject<FBResponseClass>(fbGraphResultString);
// to test google url shortner
string longurltpshorten = "https://developers.google.com/url-shortener/v1/getting_started#shorten";
var cli = new WebClient();
cli.Headers[HttpRequestHeader.ContentType] = "application/json";
string response = cli.UploadString("https://www.googleapis.com/urlshortener/v1/url", "{longUrl:\""+longurltpshorten+"\"}");
googleURLShortnerResponseClass fbGraphResults = JsonConvert.DeserializeObject<googleURLShortnerResponseClass>(response);
return new StringResult { Result = "sd"};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment