I created a dll which you can add to your .net project that allow you to shorten links for over 25 websites.
http://img827.imageshack.us/img827/9904/86691797.png
http://img195.imageshack.us/img195/1465/91673789.png
Download:
URLshorten.rar
Printable View
I created a dll which you can add to your .net project that allow you to shorten links for over 25 websites.
http://img827.imageshack.us/img827/9904/86691797.png
http://img195.imageshack.us/img195/1465/91673789.png
Download:
URLshorten.rar
Do you really need to use Bitly's DLL to shorten the URL when you are shortening everything else through RuntimeHelpers.GetObjectValue(http.GetResponse....?
It seems like a waste to require a second DLL and use it in your DLL just for one out of 25 url shorter sites.
Other than that... why are you casting the shortened URLs, which are strings, to objects? I don't see this as necessary whatsoever; in fact, I just see it as an odd nuisance.
Other than that, good job ;).
mmaybe a demo?
Most of your shortening functions functions are very similar to
So my previous statements stand ;).Code:public object idgd(string url)
{
URLshorten.Utility.Http http = this.http;
object objectValue = RuntimeHelpers.GetObjectValue(http.GetResponse("http://is.gd/create.php?format=simple&url=" + url, "", (List<DictionaryEntry>) null));
return (object) http.ProcessResponse((HttpWebResponse) objectValue, false);
}
Ah, sorry about that, the reflector that I was using must have been doing a poor job.
Nonetheless, it looked like you created a massive custom Http class? If not, than once again, I apologize for the shitty reflector.
What you have done can be done a bit simpler, by grabbing the HTML data and then using a function to strip the HTML from the returned data, which will then only return the text(the shortened URL).
The function to strip HTML tags [from the web data]:
[C#] private string StripHTML(string source) { try - Pastebin.com
With the above function, you can just use a few lines to get the shortened URL (if the website allows for data access similar to is.gd):
Once again, because of the seemingly inaccuracy of the reflector I used, I don't know if much of anything that it was showing me was even remotely what is actually there, so I don't know if this method I am showing you now is simpler or not.Code:public string idgd(string url)
{
HttpWebRequest wr = (HttpWebRequest)WebRequest.Create("http://is.gd/create.php?format=simple&url=" + url);
string html = (new StreamReader(wr.GetResponse().GetResponseStream())).ReadToEnd();
return StripHTML(html);
}
Best of luck.
P.S. The code in this post is C#
P.S.S. The StripHTML function and the few lines to get HTML data were gotten through google.
why cant you just leave him alone? If you didnt like it, then just dont post anything.
Hi Sheen; as Yamachi said, I do my very best to not post anything out of spite - especially in the coders' paradise section. Whether my replies be short or long, I do my best to make sure they have a clear and hopefully helpful point, so that the other user[s] can improve their current code.
I may have a passion for programming, but I also have a huge passion for teaching others how to program, and how to improve their programming skills. I help because I hope that (at least some of the people that I help) someone will then perhaps help others, and teach others what they have learned.
At the same time, I take any constructive criticism or suggestions people give me to heart, and I do my best to improve my current skills.
I believe that constructive criticism heavily contributes towards bettering anything that you do, whether it be coding or painting or cooking or whatever it may be that someone does.