Skip to content

Instantly share code, notes, and snippets.

@s2terminal
Created July 5, 2015 16:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save s2terminal/77210b052290aebdf7e6 to your computer and use it in GitHub Desktop.
Save s2terminal/77210b052290aebdf7e6 to your computer and use it in GitHub Desktop.
PocketFromHatena
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