https://github.com/swiftyspiffy/strawpollnet
Simple library for interfacing with the Strawpoll (original). You can create Strawpolls as well as view Strawpoll statistics.
https://github.com/swiftyspiffy/strawpollnet
api csharp poll straw strawpoll strawpollme
Last synced: 11 months ago
JSON representation
Simple library for interfacing with the Strawpoll (original). You can create Strawpolls as well as view Strawpoll statistics.
- Host: GitHub
- URL: https://github.com/swiftyspiffy/strawpollnet
- Owner: swiftyspiffy
- License: mit
- Created: 2017-01-15T04:49:35.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2019-01-31T03:47:13.000Z (over 7 years ago)
- Last Synced: 2025-03-26T15:42:33.137Z (about 1 year ago)
- Topics: api, csharp, poll, straw, strawpoll, strawpollme
- Language: C#
- Homepage: http://www.strawpoll.me/
- Size: 25.4 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# StrawpollNET - .NET Strawpoll Library for Creating and Accessing Strawpolls
[](https://www.nuget.org/packages/StrawPollNET)
### Overview
This is a simple library designed to allow for the creation and accessing of Strawpolls in a really simple fashion. Synchronous and asynchrnous calls are available and all poll details (including vote counts) are returned when creating a new poll or fetching an existing poll.
### Sample Implementations
Create Strawpoll
```
// Establish the poll settins
string pollTitle = "Which of these are great movies? You can vote on multiple!";
List allOptions = new List() { "Shrek", "Ants", "A Bug's Life", "Lion King" };
bool multipleChoice = true;
StrawPollNET.Enums.DupCheck dupCheck = StrawPollNET.Enums.DupCheck.Normal;
bool requireCaptcha = true;
// Create the poll
StrawPollNET.Models.CreatedPoll newPoll = StrawPollNET.API.Create.CreatePoll(pollTitle, allOptions, multipleChoice, dupCheck, requireCaptcha);
// Show poll link
Console.WriteLine($"Go vote at my new poll, available here: {newPoll.PollUrl}");
```
Output:
```
Go vote at my new poll, available here: https://strawpoll.me/12112663
```
Fetch a Strawpoll
```
// Get the very first Strawpoll ever made
int pollId = 1;
StrawPollNET.Models.FetchedPoll fetchedPoll = StrawPollNET.API.Get.GetPoll(pollId);
// Show results
Console.WriteLine("The current results are:");
foreach(KeyValuePair result in fetchedPoll.Results)
Console.WriteLine($"-{result.Key}: {result.Value} votes");
```
Output:
```
The current results are:
-Shrek: 1 votes
-Ants: 0 votes
-A Bug's Life: 0 votes
-Lion King: 0 votes
```
### Availability
Available via Nuget: `Install-Package StrawPollNET`
### Examples and Implementations
- StrawpollNET Example Application - This project is included in this repo as a master example project.
### Libraries Utilized
- Newtonsoft.Json - JSON parsing class. Used to parse responses from Strawpoll API
### Contributors
* Cole ([@swiftyspiffy](http://twitter.com/swiftyspiffy))
### License
MIT License. © 2016 Cole