Giter Club home page Giter Club logo

giphydotnet's Introduction

GiphyDotNet

GiphyDotNet is a simple .NET wrapper library for the Giphy API. Giphy is a search engine for gifs, enabling developers to find new and interesting ways to intergrate gifs from the Internet into their applications (and ways for people in Marketing to annoy people like me with endless amounts of Cat gifs in Slack). GiphyDotNet is a way to consume to Giphy API without having to handle the requests yourself.

Getting Started

Simply go to Nuget and download the library. You can also get it directly from the package manager.

Gif/Sticker Search

var giphy = new Giphy("apikey");
var searchParameter = new SearchParameter()
            {
                Query = "awesome"
            };
// Returns gif results
var gifResult = await giphy.GifSearch(searchParameter);

var stickerResult = await giphy.StickerSearch(searchParameter);

Gif By ID/IDs

var giphy = new Giphy("apikey");
var gifResult = await giphy.GetGifById("feqkVgjJpYtjy");
var gifsResult = await giphy.GetGifsByIds(new string[] { "feqkVgjJpYtjy", "7rzbxdu0ZEXLy" });

Random Gif/Sticker

var giphy = new Giphy("apikey");
var gifresult = await giphy.RandomGif(new RandomParameter()
{
   Tag = "american psycho"
});
var stickerresult = await giphy.RandomSticker(new RandomParameter()
{
   Tag = "american psycho"
});

Translate Into Gif/Sticker

var giphy = new Giphy("apikey");
var gifresult = await giphy.TranslateIntoGif(new RandomParameter()
{
   Tag = "american psycho"
});
var stickerresult = await giphy.TranslateIntoSticker(new RandomParameter()
{
   Tag = "american psycho"
});

Trending Gif/Stickers

var giphy = new Giphy("apikey");
var gifResult = await giphy.TrendingGifs(new TrendingParameter());
var stickerresult = await giphy.TrendingStickers(new TrendingParameter());

License

This library is licensed under the MIT License.

giphydotnet's People

Contributors

dependabot[bot] avatar drasticactions avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

giphydotnet's Issues

Version without System.Collections.Specialized

Thanks for building this. FYI that it doesn't compile on Xamarin since the NameValueCollection is not supported in that version of Mono.

A simple fix for me was to get the source code and implement my own mini-NameValueCollection. I don't have the latest code in front of me but it was something like:

public class NameValueCollection : Dictionary<string, List>
{
public void Add(string s, string o)
{
if (this.ContainsKey (s))
this [s].Add (o);
else
this [s] = new List () {o};
}

    public KeyCollection AllKeys()
    {
        return Keys;
    }

    public List<string> GetValues(string s)
    {
        return this [s];
    }

}

System.Collection.Specialized error for every execution

Hi! It is a really nice API. Makes our work much easier. :D
I'd like to use this API for giving out random gifs in a discord server.

Every time I want to execute a query and examine the gifresult object (JUst like in your tutorial) I got a

Exception: A(z) „System.Collections.Specialized, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a” fájl vagy szerelvény, illetve annak egyik függősége nem tölthető be. A rendszer nem találja a megadott fájlt.

It's says something about a missing dependency. Just like in the other issue, but I use .NET Framework 4.6

I hope you will find a solution for that. I'm going to fork this project and try to find out myself.

Could not load file or assembly 'System.Collections.Specialized

I'm trying to build a discord bot that will search for the command and show the corresponding gif but i keep getting the error System.IO.FileNotFoundException occurred
HResult=0x80070002
Message=Could not load file or assembly 'System.Collections.Specialized, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
Source=GiphyDotNet

System.IO.FileLoadException

System.IO.FileLoadException: Could not load file or assembly 'Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=##########' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Not compatible with newtonsoft.json.dll v 12.0.0.0?

RandomGif with a tag without any result, throws JsonSerializationException

Executing public async Task<GiphyRandomResult> RandomGif(RandomParameter randomParameter) with a tag that doesn't return any results, throws a JsonSerializationException.

How to reproduce:

await giphy.RandomGif(new RandomParameter()
{
    Tag = "dfafnoewiqnfopafkmasdf"
})

Cause:
GiphyRandomResult doesn't expect it's Data property to be an array. In case when there are no results, the giphy api returns data: [].
Therefor the JSON parsing here fails:

Result result = await this._webManager.GetData(new Uri("http://api.giphy.com/v1/gifs/random" + UriExtensions.ToQueryString(nvc)));
return result.IsSuccess ? JsonConvert.DeserializeObject<GiphyRandomResult>(result.ResultJson) : throw new WebException("Failed to get GIF: " + result.ResultJson);

No ImagUrl passed anymore

I think because of changes in the returned JSON result for random gifs, there's no more ImageUrl passed.
The JSON parser tries to look for "image_url", but the gif url image seems to reside under "images" -> "original" -> "url".

In fact, the only available result seems to be the gif ID, Type and Url.

This issue renders this SDK as nearly useless 😢

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.