Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C# 

Making discord bot - random imgur?

Hey guys, I've never worked with API's/requests and all that stuff.
I'm trying to make a command in my discord bot that would grab a random image from imgur gallery.
Though I do not understand how this works at all even after reading the documentation.
ap i. imgur . com /endpoints/gallery#gallery-random


Right now I tried to do
Code
       [Command("aww")]
       public async Task getRandomAww()
       {
           using (WebClient puppyClient = new WebClient())
           {
               string puppyLink = puppyClient.DownloadString("htt ps : // ap i. imgu r .c om/3/gallery/random/random/aww");
               //pull image from imgur or the link?
           }
       }

But that doesn't work because it just returns
Code
{"data":{"error":"Authentication required","request":"\/3\/gallery\/random\/random\/aww","method":"GET"},"success":false,"status":401}
this is a error-message
Code
"error":"Authentication required"

you need a imgur api key. register at developer on imgur and get your apikey
https://apidocs.imgur.com/
You need an access token
I figured out how to get a set of images from imgur gallery, but I haven't figured out how I get like the link of these images....
I know there's a .Link function but ehh D:
I'm using an imgur wrapper, which I would link if I could post links.
edit : http :// imgurapi.readthedocs . io/en/latest/endpoints/gallery-endpoint/#getsubredditgalleryasync


Code
       public async Task GetImage()
       {
           try
           {
               var client = new ImgurClient("APP-ID");
               var endpoint = new GalleryEndpoint(client);
               var images = await endpoint.GetSubredditGalleryAsync("aww");
               Console.WriteLine();// here I wanted to print the link
           }
           catch (ImgurException imgurEx)
           {
               Debug.Write("An error occurred getting an image from Imgur.");
               Debug.Write(imgurEx.Message);
           }
       }
It doesn't work if I just do images[1].Link
Anyone knows how I do this? x_x
What's the return type of GetSubredditGalleryAsync() I can't find it on their docs.
[Image: 3.gif]
(Jun 25, 2018 12:29 PM).kr. Wrote:  this is a error-message
Code
"error":"Authentication required"

you need a imgur api key. register at developer on imgur and get your apikey

You don't need an API key, just go to the home page ( or category page ) and download every image by <img>/<image> tag, then scroll down

this is a webbrowser method i used to scrape 2.77M Images
(Jun 27, 2018 05:50 AM)Infirmary Wrote:  You don't need an API key, just go to the home page ( or category page ) and download every image by <img>/<image> tag, then scroll down

this is a webbrowser method i used to scrape 2.77M Images

this is a retarded way, do not use the way this retard said to do it.
(Jun 27, 2018 06:26 AM)int Wrote:  this is a retarded way, do not use the way this retard said to do it.

Why??

WebBrowser could suck but as long as you use proxies for scraping tons of images, Could Violate TOS..
(Jun 27, 2018 06:29 AM)Infirmary Wrote:  Why??

WebBrowser could suck but as long as you use proxies for scraping tons of images, Could Violate TOS..

webbrowser is for retards and scraping images, downloading, and sending to discord is for retards.
Who would wanna use Imgur's API, it sucks..

Use a Webbrowser without the window ( not giving code ) and ignore this guy..
(Jun 27, 2018 06:34 AM)Infirmary Wrote:  Who would wanna use Imgur's API, it sucks..

Use a Webbrowser without the window ( not giving code ) and ignore this guy..

so ur telling me instead of sending a link to an image on discord,
you want to download the image, upload to discord, and send the uploaded link?
iq 10
(Jun 27, 2018 07:18 AM)int Wrote:  so ur telling me instead of sending a link to an image on discord,
you want to download the image, upload to discord, and send the uploaded link?
iq 10

Did I say a link.. Do i have to explain everything ??

Plus, You can Download then upload image & delete a Downloaded image

iq 10 means idiots like you need to ask self-explanatory questions..

P.S. It's pretty obvious.. IF you arent "iq 10" that someone shouldn't have to explain everything to you at once
yeah ok retard, let me know when u get a brain to use an api
(Jun 27, 2018 07:28 AM)int Wrote:  yeah ok retard, let me know when u get a brain to use an api

Whatever. API's cost performance & Money 🤭 😎
Here's a sample project. You need to implement your own way to see if a picture redirects to removed.png though https://files.catbox.moe/rtryeq.zip

[Image: EUTrXql.gif]
[Image: Syr3DlV.png]


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C#] by Memento_MoriJan 18, 2022 07:09 PM 2 261 Jan 18, 2022 07:09 PM
Last Post: DDDealer
[.NET] by System[X]Feb 21, 2019 02:45 PM 2 361 Feb 21, 2019 02:45 PM
Last Post: System[X]
[Python] by MrbadguyApr 30, 2017 07:21 AM 9 269 Apr 30, 2017 07:21 AM
Last Post: Mrbadguy