Coder Social home page Coder Social logo

naikdeepak / yelpsharp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from justinbeckwith/yelpsharp

0.0 1.0 0.0 6.62 MB

YelpSharp is a .NET wrapper for the Yelp REST API. It lets you do all kinds of interesting things like searching for businesses, getting user comments and ratings, and handling common errors. The library is written in C#, and available on NuGet.

C# 98.28% Shell 1.72%

yelpsharp's Introduction

YelpSharp

YelpSharp is a .NET wrapper for the Yelp REST API. It lets you do all kinds of interesting things like searching for businesses, getting user comments and ratings, and handling common errors. The library is written C#, and is available on NuGet.

For more information, visit the Yelp REST API

Installing

In most cases, you're going to want to install the YelpSharp NuGet package. Open up the Package Manager Console in Visual Studio, and run this command:

PM> Install-Package YelpSharp

How to Use

The source includes a few examples that should help you get started with ASP.NET and Windows Phone 8. Before you get started, you need to register for a Yelp developer account, and register for an API key. If you are looking for something and having trouble, you can always check out the unit tests.

Handling Tokens

The Yelp constructor takes a set of options that includes all of the keys neccesary to use the V2 Yelp API. Keep these keys safe! There are a variety of ways to store them. You can put them in the applicationSettings portion of your web.config (recommended), or store them in an environment variable on your dev machine:

var options = new Options()
{
    AccessToken = Environment.GetEnvironmentVariable("YELP_ACCESS_TOKEN", EnvironmentVariableTarget.Machine),
    AccessTokenSecret = Environment.GetEnvironmentVariable("YELP_ACCESS_TOKEN_SECRET", EnvironmentVariableTarget.Machine),
    ConsumerKey = Environment.GetEnvironmentVariable("YELP_CONSUMER_KEY", EnvironmentVariableTarget.Machine),
    ConsumerSecret = Environment.GetEnvironmentVariable("YELP_CONSUMER_SECRET", EnvironmentVariableTarget.Machine)
};

For a full example of conviently storing your tokens, check out the MvcSample.

Using the Search API

YelpSharp uses the Task Parallel Library (TPL) to make managing asynchronous requests easier. The search API has two different ways of searching for results. The simplest way is to pass a city and a search term. This will search Yelp for all coffee places around Seattle, WA (there are a lot).

var task = y.Search("coffee", "seattle, wa").ContinueWith((searchResults) =>
{
    foreach (var business in searchResults.Result.businesses)
    {
        Console.WriteLine(business.name);
    }
});

There are a lot of other ways to search. For more info, the best place to look is the unit tests.

Building the Source

If you want to build the source, clone the repository, and open up YelpSharp.sln.

git clone https://github.com/JustinBeckwith/YelpSharp
explorer YelpSharp\YelpSharp.sln

Supported Platforms

YelpSharp targets .NET 4.0, and Windows Phone 8. If you would like support for other platforms, let me know.

License

MIT License

Questions?

Feel free to submit an issue on the repository, or find me at @JustinBeckwith

yelpsharp's People

Contributors

justinbeckwith avatar thejoecode avatar dlsteuer avatar haiderabbas avatar waywardmage avatar swegner avatar tugberkugurlu avatar

Watchers

Deepak avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.