How to use API and operate it with toolbox items

Posts 1–8 of 8 · Page 1 of 1
How to use API and operate it with toolbox items
I'm pretty advanced with vb.netⓘ, but have no idea how to use an API! Let's say I can get my hands on a skype, pastebin, imgur api. How would I use this in my project? Thanks!
top menu in msvs: Project-->Add Reference

3 tabs (?) : .net | com | browse

maybe you'll find it in the first 2, if not try browse -- I think it automatically copies the dll into the build folder.


To use it (and vb does it own unique thing when it comes importing namespaces for you?) you can try

Code:
Imports ProductNamespace
''Imports must at top of class declaration
or
Dim myObject As ProductNamespace.SeeIntellisense
maybe?

Not sure about toolbox items.
edit: Right click on a clear area in the toolbox and "Choose Items"
a few tabs: check .net and com probably.
?
Quote Originally Posted by abuckau907 View Post
Not sure about toolbox items.
Right-Click within the Toolbox.
>Choose Items...
>>Then Browse...

>Find the .DLL File, and Open it
Took me 2 minutes to pull up msvs and check. Beat me too it.

---------- Post added at 02:49 AM ---------- Previous post was at 02:48 AM ----------

Quote Originally Posted by Jorndel View Post


Right-Click within the Toolbox.
>Choose Items...
>>Then Browse...

>Find the .DLL File, and Open it
Speedy. Thnx.
Quote Originally Posted by abuckau907 View Post
Took me 2 minutes to pull up msvs and check. Beat me too it.
That's because I knew how


But I'm glad to see you're helping out people.
-I'm grateful for your contribution
Quote Originally Posted by xBear Grylls View Post
I'm pretty advanced with vb.netⓘ, but have no idea how to use an API! Let's say I can get my hands on a skype, pastebin, imgur api. How would I use this in my project? Thanks!
API's come in different forms and processes.. I guess I could say. Basically.. an API, such as imgur or pastebin, is a web client based method that allows your program to communicate in and out of a website. Like Pastebin, you could set up an API registration that gives you the unique keys that are required for you to use the website API.
I'd suggest reading over Pastebin API details for a better understanding. Pastebin.com - Login Pageⓘ

To actually use the API, you can you'll need to send a url based string, which API's are based off of in this case. To do that, simply send a webrequest POST method.

Code:
Dim postReq As HttpWebRequest = DirectCast(WebRequest.Create(URL), HttpWebRequest)
postReq.Method = "POST"
After requesting, you'll need to retrieve the data you get from the request by getting a response.
Code:
Dim postreqstream As Stream = postReq.GetRequestStream()
postreqstream.Write(byteData, 0, byteData.Length)
postreqstream.Close()
Dim postresponse As HttpWebResponse
postresponse = DirectCast(postReq.GetResponse(), HttpWebResponse)
Dim postreqreader As New StreamReader(postresponse.GetResponseStream())
Dim thepage As String = postreqreader.ReadToEnd

but before you can do all that, you'll have to enter a url requesting what exactly you want to get. An example would be..
Code:
Dim Post = "api_option=paste&api_dev_key=" & DevKey & _
                            "&api_paste_code=" & PasteData & _
                            "&api_paste_private=" & Exposure & _
                            "&api_paste_name=" & Title & _
                            "&api_paste_expire_date=" & Expire & _
                            "&api_paste_format=" & Syntax & _
                            "&api_user_key=" & UserKey & _
                            "&api_paste_name=" & Title
Think of each part as a parameter of a function that you need to have for it to work. If it doesn't work, it'll return a specific string on why it hasn't work.

This should be enough to get you started, although the code that I have is incomplete. Good luck

or like what they said ^
API's can come in .net assembly files


Quote Originally Posted by DawgiiStylz View Post

API's come in different forms and processes.. I guess I could say. Basically.. an API, such as imgur or pastebin, is a web client based method that allows your program to communicate in and out of a website. Like Pastebin, you could set up an API registration that gives you the unique keys that are required for you to use the website API.
I'd suggest reading over Pastebin API details for a better understanding. Pastebin.com - Login Pageⓘ

To actually use the API, you can you'll need to send a url based string, which API's are based off of in this case. To do that, simply send a webrequest POST method.

Code:
Dim postReq As HttpWebRequest = DirectCast(WebRequest.Create(URL), HttpWebRequest)
postReq.Method = "POST"
After requesting, you'll need to retrieve the data you get from the request by getting a response.
Code:
Dim postreqstream As Stream = postReq.GetRequestStream()
postreqstream.Write(byteData, 0, byteData.Length)
postreqstream.Close()
Dim postresponse As HttpWebResponse
postresponse = DirectCast(postReq.GetResponse(), HttpWebResponse)
Dim postreqreader As New StreamReader(postresponse.GetResponseStream())
Dim thepage As String = postreqreader.ReadToEnd

but before you can do all that, you'll have to enter a url requesting what exactly you want to get. An example would be..
Code:
Dim Post = "api_option=paste&api_dev_key=" & DevKey & _
                            "&api_paste_code=" & PasteData & _
                            "&api_paste_private=" & Exposure & _
                            "&api_paste_name=" & Title & _
                            "&api_paste_expire_date=" & Expire & _
                            "&api_paste_format=" & Syntax & _
                            "&api_user_key=" & UserKey & _
                            "&api_paste_name=" & Title
Think of each part as a parameter of a function that you need to have for it to work. If it doesn't work, it'll return a specific string on why it hasn't work.

This should be enough to get you started, although the code that I have is incomplete. Good luck

or like what they said ^
API's can come in .net assembly files


I cant thank you enough! Resolved.
Posts 1–8 of 8 · Page 1 of 1

Post a Reply

Similar Threads

Tags

None

Talk with us