From c91c0b0bf2453b02dc921de7f9c29d04ade743cc Mon Sep 17 00:00:00 2001 From: mohjak Date: Sun, 18 Feb 2018 08:53:18 +0300 Subject: [PATCH] Enhance the layout of the file * Correct headers markdown padding. * Add prefix and suffix for code blocks. --- README.md | 71 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 41 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index 58e7b8a..d6ae981 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,34 @@ -#oAuthTwitterWrapper +# oAuthTwitterWrapper + This provides a really simple solution to authenticating and wrapping twitter's API calls using the 1.1 API and OAuth. -##Quick installation instructions: +## Quick installation instructions: Run the following nuget command from your project to install the [package] (http://nuget.org/packages/oAuthTwitterWrapper/): -`Install-Package oAuthTwitterWrapper` +```powershell +Install-Package oAuthTwitterWrapper +``` Amend the appsettings to add your consumer key, secret and screen name. [Generate your key and secret here] (https://dev.twitter.com/apps/new) Add the following code to return the raw json: - var twit = new OAuthTwitterWrapper.OAuthTwitterWrapper(); - twit.GetMyTimeline(); +```c# +var twit = new OAuthTwitterWrapper.OAuthTwitterWrapper(); +twit.GetMyTimeline(); +``` If you would prefer to use serialiazed C# pocos use the following: - var twit = new OAuthTwitterWrapper.OAuthTwitterWrapper(); - var json = twit.GetMyTimeline(); - var tweets = JsonConvert.DeserializeObject>(json); // Deserialize with Json.NET +```c# +var twit = new OAuthTwitterWrapper.OAuthTwitterWrapper(); +var json = twit.GetMyTimeline(); +var tweets = JsonConvert.DeserializeObject>(json); // Deserialize with Json.NET +``` + +# Notes -#Notes Currently it exposes timeline (twitter feed) and search calls, returned as raw json (which can be serialized into c# pocos, examples in the github project). Screen shot below (please note there is no styling applied you have full control over how it is rendered in your application). @@ -57,29 +65,32 @@ Amend the appsettings to add your consumer key, secret and screen name. [Generat Create a macro script with the following code that outputs the json inline to the page: - @using System - @{ - var twit = new OAuthTwitterWrapper.OAuthTwitterWrapper(); - var json = twit.GetMyTimeline(); - } +```c# +@using System +@{ + var twit = new OAuthTwitterWrapper.OAuthTwitterWrapper(); + var json = twit.GetMyTimeline(); +} + +
+ +``` -
- - Add a reference to jQuery and twitter-text, then add some javascript to parse the json (The code here is just used for example purposes and not best practice): - for (var i = 0; i < json.length; i++) { - $("#results").append('

- ' + json[i].created_at.substring(0, 16) + '
' + twttr.txt.autoLink(json[i].text) + '

'); - try { - for (var j = 0; j < json[i].entities.media.length; j++) { - $("#results").append(''); - } - - } catch(e) { - } - } - +```c# +for (var i = 0; i < json.length; i++) { + $("#results").append('

- ' + json[i].created_at.substring(0, 16) + '
' + twttr.txt.autoLink(json[i].text) + '

'); +try { + for (var j = 0; j < json[i].entities.media.length; j++) { + $("#results").append(''); + } + + } catch(e) { + } +} +``` Add the macro to the template or content within Umbraco.