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

.NET 

[Updated][TUT][SRC]Adfly link genrator[How to use httpwebrequests]♂♀

Introduction:- In this tutorial we are going to make a simple app which will convert our urls to Adfly links.

Step1:- First we have to get the api code from adfly.

Login to your adfly account.
Click on the "Tools" Link.
[IMG]http://girlzlist.0fees.net/?di=113148097844[/IMG]

Then Click on Api Documentation
[IMG]http://girlzlist.0fees.net/?di=1213148097847[/IMG]

Then copy everything that's in the white space.
[IMG]http://girlzlist.0fees.net/?di=1131480978415[/IMG]

Step 2:- Now lets move to Visual Basic.

Open Visual Basic/Studio and create a new Windows Form Application, name it anything you want.
[IMG]http://girlzlist.0fees.net/?di=113148097842[/IMG]

Add two text boxes and two buttons. Change the properties according to image below.
[IMG]http://girlzlist.0fees.net/?di=15131480991215[/IMG]

Now add this code to the form
[IMG]http://girlzlist.0fees.net/?di=10131480978514[/IMG]

Explanation:-
Code
Imports System.IO
Imports System.Net
This will import the System.Net and System.IO namespaces to our Project.

Code
Dim url As String = ""
    Dim adfly As String = ""
    Dim api As String = "http://api.adf.ly/api.php?key=77b6d5d20c3e2ac190c784fb36847150&uid=75738&advert_type=int&domain=adf.ly&url="

This declares some string variable for later use in the project. Paste the api link you copied from step one. Remove the part after the "=" sign(http://somewebsite.com")

Code
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  url = txtUrl.Text.Trim()
  api = api & url
  Dim req As HttpWebRequest = HttpWebRequest.Create(New Uri(api))
  Dim res As HttpWebResponse = req.GetResponse()
  adfly = New StreamReader(res.GetResponseStream).ReadToEnd
  txtAdfly.Text = adfly
End Sub

What this does is first put the string from txtUrl textbox to the url variable. Then adds the url to api variable. What we have done is removed http://somewebsite.com and added our url here.

Now we have created a new httpWebRequest as req with the api url. This will send a request to adfly for shortening the url with our id.
Next we created a HttpWebResponse and assigned it to recieve the message from req.

In the last part we create a temporary StreamReader to get the response from "res" by accessing the ResponseStream(using the getresponse propery). ReadToEnd method read everything.

Atlast we have put the link we got from response into txtAdfly textbox.

Code
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  My.Computer.Clipboard.SetText(txtAdfly.Text)
    End Sub
End Class

This just copies the adfly link to clipboard.

Further Improvements:-


You can create a mass link generator where you can read all the links from a textfile and generate links.

You can even make it with just one textbox and one button, even without a button.

Source:-Post here and I will send you.

Hope you like this tutorial. Please donate to my paypal("[email protected]") I know this is not a tutorial worth donating money but I need it.

Please post in the thread
Yay First! Woho!!

Good Tutorial! :D
ya nice tutorial mate easy to understand 😉
"Sympathy", you can get it by anyone but, "Jealousy" you have to earn it.
Thanks guys. Good comments will motivate me to write more good tutorials.
You really should have the API key as a constant in this instance.
[Image: Xtddh8V.png]
(Aug 31, 2011 11:06 PM)Fake. Wrote:  You really should have the API key as a constant in this instance.

Yeah, but i am using the same variable for creating the request, so...



Bump after updating a few things.

this msg must not be shrt.
i love the tutorial , thanks a lot
Is it just me or are the images not working?
(Sep 3, 2011 03:28 PM)joker-vl Wrote:  i love the tutorial , thanks a lot

Thanks guy, I will write some more.

(Sep 3, 2011 03:37 PM)Wet Wrote:  Is it just me or are the images not working?

They are working for me. try refreshing again and agian and agian


Possibly Related Threads...
Thread / Author Replies Views Last Post
[.NET] by sh@rpJul 5, 2020 07:05 AM 212 22,346 Jul 5, 2020 07:05 AM
Last Post: sh@rp
[C#] by RawrrasaurusMay 14, 2019 05:18 PM 4 335 May 14, 2019 05:18 PM
Last Post: JUSTIN
[C#] by fortress1999May 28, 2016 12:22 PM 7 187 May 28, 2016 12:22 PM
Last Post: 0xDEAD10CC