forked from ServiceStack/ServiceStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIOAuthHttpGateway.cs
More file actions
37 lines (30 loc) · 1019 Bytes
/
IOAuthHttpGateway.cs
File metadata and controls
37 lines (30 loc) · 1019 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using ServiceStack.Common;
using ServiceStack.ServiceClient.Web;
using ServiceStack.Text;
namespace ServiceStack.ServiceInterface.Auth
{
public interface IOAuthHttpGateway
{
string DownloadTwitterUserInfo(string twitterUserId);
string DownloadFacebookUserInfo(string facebookCode);
}
public class OAuthHttpGateway : IOAuthHttpGateway
{
public const string TwitterUserUrl = "http://api.twitter.com/1/users/lookup.json?user_id={0}";
public const string FacebookUserUrl = "https://graph.facebook.com/me?access_token={0}";
public string DownloadTwitterUserInfo(string twitterUserId)
{
twitterUserId.ThrowIfNullOrEmpty("twitterUserId");
var url = TwitterUserUrl.Fmt(twitterUserId);
var json = url.DownloadUrl();
return json;
}
public string DownloadFacebookUserInfo(string facebookCode)
{
facebookCode.ThrowIfNullOrEmpty("facebookCode");
var url = FacebookUserUrl.Fmt(facebookCode);
var json = url.DownloadUrl();
return json;
}
}
}