Git Product home page Git Product logo

sharpsquare's Introduction

SharpSquare

FourSquare SDK for .NET

The SharpSquare .NET library provides a quick access to the FourSquare API v2. The library is built in C# and can therefore be used by all languages the .NET environment supports.

Beacuse of clean natural object oriented approach, the library is easy to use. SharpSquare implements almost all the features offered by the FourSquare API and fully supports the oAuth protocol.

Each API call is mapped to a one-to-one method and each FourSquare entity is mapped to a class.

Code examples

using FourSquare.SharpSquare.Core;
using FourSquare.SharpSquare.Entities;

string clientId = "CLIENT_ID";
string clientSecret = "CLIEND_SECRET";
string redirectUri = "REDIRECT_URI";
SharpSquare sharpSquare = new SharpSquare(clientId, clientSecret);

Authentication

if (Request["code"] != null)
{
	sharpSquare.GetAccessToken(redirectUri, Request["code"]);
	// Here, you can do something
}
else
{
	HyperLink.NavigateUrl = sharpSquare.GetAuthenticateUrl(redirectUri);
}

Create a check-in

Dictionary<string, string> parameters = new Dictionary<string, string>();
parameters.Add("venueId", "VENUE_ID");
parameters.Add("broadcast", "public");
Checkin checkin = sharpSquare.AddCheckin(parameters);

sharpsquare's People

Contributors

ismcagdas avatar petroprots avatar rustem-net avatar ticlab avatar trevorloader avatar udzin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sharpsquare's Issues

Error in SearchVenues

Today my application started showing error 410 message in the search operation. I did a little debugging and find it would be something new requirement of the foursquare api related to parameter "V" . So resolve to upgrade SharpSquare to the latest version that is here in github, however I am having the error below:

Msg:
Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'FourSquare.SharpSquare.Entities.FourSquareEntityItems`1[FourSquare.SharpSquare.Entities.Venue]' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly.

To fix this error either change the JSON to a JSON object (e.g. {"name":"value"}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List that can be deserialized from a JSON array. JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array.

Path 'response.neighborhoods', line 1, position 50.

Here:
public List SearchVenues(Dictionary<string, string> parameters)
{
FourSquareEntityItems venues = GetSingle<FourSquareEntityItems>("/venues/search", parameters, true).response["groups"];

        return venues.items;
    }

issue with deserializing data for venue search

When I do a call to get the venues "near" "Biloxi, Ms" the json is coming back correctly from foursquare correctly but I am not able to deserialize it, I keep getting this error:

An exception of type 'Newtonsoft.Json.JsonSerializationException' occurred in Newtonsoft.Json.dll but was not handled in user code

Additional information: Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'FourSquare.SharpSquare.Entities.FourSquareEntityItems`1[FourSquare.SharpSquare.Entities.Venue]' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly.

To fix this error either change the JSON to a JSON object (e.g. {"name":"value"}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List that can be deserialized from a JSON array. JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array.

Path 'response.neighborhoods', line 1, position 50.

Is anyone else having this problem?

Cannot deserialize the current JSON array

Hello,

I am new arround here and i tried using SharpSquare. I tried to build a simple app by i am getting this result. ( at the end of the post )

Can you guys help me out ?

Do i need token or something ? How do i do that ?

SharpSquare sharpSquare = new SharpSquare("Client id", "Client secret");

Dictionary<string, string> parameters = new Dictionary<string, string>();
parameters.Add("ll", "51.508515,-0.1254872");
parameters.Add("categoryId", "4d4b7105d754a06374d81259"); //Food
parameters.Add("radius", "5000");
parameters.Add("limit", "50");
var result = sharpSquare.SearchVenues(parameters);

result.Wait();

ERROR 👍

  •   Thrown: "Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'FourSquare.SharpSquare.Entities.FourSquareEntityItems`1[FourSquare.SharpSquare.Entities.Venue]' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly.
    
    To fix this error either change the JSON to a JSON object (e.g. {"name":"value"}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List that can be deserialized from a JSON array. JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array.
    Path 'response.venues', line 1, position 43." (Newtonsoft.Json.JsonSerializationException) Exception Message = "Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'FourSquare.SharpSquare.Entities.FourSquareEntityItems`1[FourSquare.SharpSquare.Entities.Venue]' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly.\r\nTo fix this error either change the JSON to a JSON object (e.g. {"name":"value"}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List that can be deserialized from a JSON array. JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array.\r\nPath 'response.venues', line 1, position 43.", Exception Type = "Newtonsoft.Json.JsonSerializationException", Exception WinRT Data = null

"The remote server returned an error: (403) Forbidden" exception in GetManagedVenues

Changing unauthenticated property from true to false solved 403 Forbidden but raises new Json exception.

Changing GetMultiple method to GetSingle solved Json exception.

//Bug in GetManagedVenues() Method

List<FourSquareEntityItems<Venue>> venueGroups = GetMultiple<FourSquareEntityItems<Venue>>("/venues/managed", parameters, false).response["venues"];

//Solved replacing that line with this

FourSquareEntityItems<Venue> venues = GetSingle<FourSquareEntityItems<Venue>>("/venues/managed", parameters, false).response["venues"];

add versioning

I just tried , and it is an Gone response.

Please add to the
private string Request(string url, HttpMethod httpMethod, string data)
add this
url = url + "&v=20140101";

added versioning

Now foursquare have modified his API. They require a versioning
See https://developer.foursquare.com/overview/versioning
More, they say:
"As of January 28, 2014, requests that do not include a v parameter will be rejected."
The change is easy to do:
In the
private string Request(string url, HttpMethod httpMethod, string data)
add this
url = url + "&v=20140101";

Checkin problem

Objects Changed we cannot parse the response a Checkin Object needs to be revamped

How to get venues/explore?

I'm using Sharpsquare and I've been using venues/trending with no problem. However, I need to switch to venues/explore endpoint to sort venues by distance and I need some more logic.

However, I couldn't be sure which method maps to the venues/explore endpoint. I've seen trending and search, but they are different. I specifically need the explore endpoint.

Which one is it?

add following properties

please add property:notifications to classFourSquare.SharpSquare.Core.FourSquar
SingleResponse1[[FourSquare.SharpSquare.Entities.FourSquareEntityItems1[[Four
quare.SharpSquare.Entities.Checkin, SharpSquare, Version=1.0.0.0, Culture=neutr
l, PublicKeyToken=null]], SharpSquare, Version=1.0.0.0, Culture=neutral, Public
eyToken=null]] value:[{"type":"notificationTray","item":{"unreadCount":0}}]
error for class:responseNo parameterless constructor defined for type of 'Syste
.String'.
error for class:checkinsNo parameterless constructor defined for type of 'Syste
.String'.
error for class:itemsNo parameterless constructor defined for type of 'System.S
ring'.
Value cannot be null.
Parameter name: timeZoneOffset
please add property:timeZoneOffset to classFourSquare.SharpSquare.Entities.Chec
in value:120
error for class:venueNo parameterless constructor defined for type of 'System.S
ring'.
error for class:categoriesNo parameterless constructor defined for type of 'Sys
em.String'.
not a simple property icon from FourSquare.SharpSquare.Entities.Category value:
"prefix":"https://ss1.4sqi.net/img/categories_v2/building/home_","suffix":".png
}
Value cannot be null.
Parameter name: likes
please add property:likes to classFourSquare.SharpSquare.Entities.Checkin value
{"count":0,"groups":[]}
Value cannot be null.
Parameter name: like
please add property:like to classFourSquare.SharpSquare.Entities.Checkin value:
alse
Value cannot be null.
Parameter name: posts
please add property:posts to classFourSquare.SharpSquare.Entities.Checkin value
{"count":0,"textCount":0}

More details about how I discpvered on my blog next week

Search Multiple Venue issue

Hi guys.

I try used SharpSquare to find venues by coordinates("ll");
But i had some problems with SearchVenues method.

    public List<Venue> SearchVenues(Dictionary<string, string> parameters)
    {
        FourSquareEntityItems<Venue> venues = GetSingle<FourSquareEntityItems<Venue>>("/venues/search", parameters, true).response["groups"];

        return venues.items;
    }

This method invoke "GetSingle" Venue, but i search for Multiple, so this method must invoke "GetMultiple".

Sorry for my english.

Cannot pull venue tips

I started getting errors today because I didn't have versioning enabled. I added that parameter and the JSON is now being properly returned but the deserialization process now returns "No parameterless constructor defined for type of 'System.String'." as an error at line 118 of the code.

Any ideas??

GetUserFriends throw casting error

In trying to retrieve my friend-list, I'm getting the Exception below. I tested several other methods successfully, so I know auth isn't an issue here.

'foursquare.GetUserFriends("334497")' threw an exception of type 'Newtonsoft.Json.JsonSerializationException'
base: {"Error converting value "21ac47b2cca3eba81920042c710541a5058336f8" to type 'FourSquare.SharpSquare.Entities.FourSquareEntityItems`1[FourSquare.SharpSquare.Entities.User]'. Path 'response.checksum', line 1, position 25143."}

GetUserVenueHistory does not honor parameters

please modify adding parameters
public List GetUserVenueHistory(Dictionary<string, string> parameters)
{
//andrei
FourSquareEntityItems venues = GetSingle<FourSquareEntityItems>("/users/self/venuehistory",parameters).response["venues"];

        return venues.items;
    }

error in checkins

After solving
#3

there is something strange in obtaining checkins:
The json is

{"meta":{"code":200},"notifications":[{"type":"notificationTray","item":{"unreadCount":0}}],"response":{"checkins":{"count":3109,"items":[{"id":"52e94401498eeae5a187fc68","createdAt":1391019009,"type":"checkin","isMayor":true,"timeZoneOffset":120,"venue":{"id":"51a9fc88498e943d4164213f","name":"casa","contact":{},"location":{"isFuzzed":true,"lat":44.41826985075991,"lng":26.04705597207766,"cc":"RO","country":"Romania"},"categories":[{"id":"4bf58dd8d48988d103941735","name":"Home (private)","pluralName":"Homes (private)","shortName":"Home","icon":{"prefix":"https://ss1.4sqi.net/img/categories_v2/building/home_","suffix":".png"},"primary":true}],"verified":false,"stats":{"checkinsCount":396,"usersCount":1,"tipCount":0},"likes":{"count":1,"groups":[],"summary":"You"},"like":true,"beenHere":{"count":396,"marked":false}},"likes":{"count":0,"groups":[]},"like":false,"photos":{"count":0,"items":[]},"posts":{"count":0,"textCount":0},"comments":{"count":0},"source":{"name":"foursquare for Android","url":"https://foursquare.com/download/#/android"}},{"id":"52e8b2d5498eea1e7c2a9509","createdAt":1390981845,"type":"checkin","isMayor":true,"timeZoneOffset":120,"venue":{"id":"4b968374f964a52044d134e3","name":"Ubisoft România","contact":{"phone":"0215690661","formattedPhone":"021 569 0661","twitter":"ubisoft"},"location":{"address":"Bd. Expoziției nr. 2, etaj 4","crossStreet":"str. Parcului","lat":44.47349645922998,"lng":26.057950258255005,"postalCode":"012101","cc":"RO","city":"București","country":"Romania"},"categories":[{"id":"4bf58dd8d48988d125941735","name":"Tech Startup","pluralName":"Tech Startups","shortName":"Tech Startup","icon":{"prefix":"https://ss1.4sqi.net/img/categories_v2/shops/technology_","suffix":".png"},"primary":true}],"verified":false,"stats":{"checkinsCount":2878,"usersCount":164,"tipCount":5},"url":"http://ubisoft.ro","likes":{"count":14,"groups":[{"type":"others","count":14,"items":[]}],"summary":"14 likes"},"like":false,"beenHere":{"count":597,"marked":false},"listed":{"groups":[{"type":"created","count":1,"items":[]}]}},"likes":{"count":0,"groups":[]},"like":false,"photos":{"count":0,"items":[]},"posts":{"count":0,"textCount":0},"comments":{"count":0},"source":{"name":"foursquare for Android","url":"https://foursquare.com/download/#/android"}},{"id":"52e8a9a1498eea1e7c2a5cf2","createdAt":1390979489,"type":"checkin","isMayor":true,"timeZoneOffset":120,"venue":{"id":"50229448e4b007e779a9ffcb","name":"Statie 41 Agronomie","contact":{},"location":{"lat":44.47160486443555,"lng":26.07227650155098,"cc":"RO","country":"Romania"},"categories":[{"id":"4bf58dd8d48988d1fc931735","name":"Light Rail","pluralName":"Light Rails","shortName":"Light Rail","icon":{"prefix":"https://ss1.4sqi.net/img/categories_v2/travel/lightrail_","suffix":".png"},"primary":true}],"verified":false,"stats":{"checkinsCount":75,"usersCount":41,"tipCount":0},"likes":{"count":1,"groups":[{"type":"others","count":1,"items":[{"id":"60998954","firstName":"Oliver","lastName":"P.","gender":"male","photo":{"prefix":"https://irs0.4sqi.net/img/user/","suffix":"/GZKOOWUAZNSABFAA.jpg"}}]}],"summary":"Oliver Popa"},"like":false,"beenHere":{"count":17,"marked":false}},"likes":{"count":0,"groups":[]},"like":false,"photos":{"count":0,"items":[]},"posts":{"count":0,"textCount":0},"comments":{"count":0},"source":{"name":"foursquare for Android","url":"https://foursquare.com/download/#/android"}},{"id":"52e87ba311d2418c4c62e043","createdAt":1390967715,"type":"checkin","shout":"Up","isMayor":true,"timeZoneOffset":120,"venue":{"id":"51a9fc88498e943d4164213f","name":"casa","contact":{},"location":{"isFuzzed":true,"lat":44.41826985075991,"lng":26.04705597207766,"cc":"RO","country":"Romania"},"categories":[{"id":"4bf58dd8d48988d103941735","name":"Home (private)","pluralName":"Homes (private)","shortName":"Home","icon":{"prefix":"https://ss1.4sqi.net/img/categories_v2/building/home_","suffix":".png"},"primary":true}],"verified":false,"stats":{"checkinsCount":396,"usersCount":1,"tipCount":0},"likes":{"count":1,"groups":[],"summary":"You"},"like":true,"beenHere":{"count":396,"marked":false}},"likes":{"count":0,"groups":[]},"like":false,"photos":{"count":0,"items":[]},"posts":{"count":0,"textCount":0},"comments":{"count":0},"source":{"name":"foursquare for Android","url":"https://foursquare.com/download/#/android"}}]}}}

but when deserializing in
FourSquareSingleResponse fourSquareResponse = new JavaScriptSerializer().Deserialize<FourSquareSingleResponse>(json);
( T is a Checkin)
the error is
{"No parameterless constructor defined for type of 'System.String'."}
with inner exception null.
I suppose that the json have changed - but how ?
Thank you for your time

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.