Created
July 5, 2015 16:11
-
-
Save s2terminal/77210b052290aebdf7e6 to your computer and use it in GitHub Desktop.
PocketFromHatena
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace PocketFromHatena.Controllers | |
{ | |
public class ValuesController : ApiController | |
{ | |
public class HatenaValues | |
{ | |
public string Url { get; set; } | |
public string Key { get; set; } | |
} | |
// POST api/values | |
public Boolean Post(HatenaValues values) | |
{ | |
string pocket_api = "https://getpocket.com/v3/add"; | |
string hatena_webhook = "xxxxxxxx"; | |
string pocket_consumer_key = "xxxxxxxx"; | |
string pocket_access_token = "xxxxxxxx"; | |
if (hatena_webhook != values.Key) | |
{ | |
return false; | |
} | |
System.Net.WebClient wc = new System.Net.WebClient(); | |
System.Collections.Specialized.NameValueCollection ps = new System.Collections.Specialized.NameValueCollection(); | |
ps.Add("url", values.Url); | |
ps.Add("tags", "hatena"); | |
ps.Add("consumer_key", pocket_consumer_key); | |
ps.Add("access_token", pocket_access_token); | |
byte[] resData = wc.UploadValues(pocket_api, ps); | |
wc.Dispose(); | |
return true; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment