473,387 Members | 1,440 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to use Tinyurl.com dynamically

I have a feedback Form from which my visitors send their views. At times, I see very long URLs get submitted via my Form and get entered into my database. But, when displaying the URL, my page gets distorted..

Is there a way I can script this so I can automatically convert this long URL to a small url using TinyURLcom for instance - like what Twitter does..

i.e. I want to shorten this long URL automatically before it is inserted into the database

From:
Expand|Select|Wrap|Line Numbers
  1. http://rover.ebay.com/rover/1/711-53200-19255-0/1?t
  2. ype=3&campid=5336224516&toolid=10001&customid=tiny-
  3. hp&ext=unicycle&satitle=unicycle
To
Expand|Select|Wrap|Line Numbers
  1. http://tinyurl.com/bv5tgg
Thank you.

-AJ
Jun 25 '09 #1
3 5401
acoder
16,027 Expert Mod 8TB
If you want to create a Tiny URL.com URL, then you will have to make a HTTP request to the create.php page of TinyURL.com, but if the only reason for this is the display, then how about shortening the URL when displaying, e.g.
Expand|Select|Wrap|Line Numbers
  1. <a href="http://rover.ebay.com/rover/1/711-53200-19255-0/1?type=3&campid=5336224516&toolid=10001&customid=tiny-hp&ext=unicycle&satitle=unicycle">http://rover.ebay.com/...</a>
or specify link text as well as the link itself.
Jun 25 '09 #2
aCoder -

Your solution would work only if I have a field that collects URLs only, however, my field is a textarea, the visitors are allowed to put text in this field, but at times, they paste URLs too within the text – that is the issue I am facing with.

If there is a long URL berried within the text, how do I shorten it or worse case scenario, how do I prevent/strip a URL before it gets inserted into the database.

Thanks
-AJ
Jun 25 '09 #3
acoder
16,027 Expert Mod 8TB
Oh, I see. Well, in that case, parse the field value. You could use a regular expression to replace links with the shorter display by using REReplace.
Jun 26 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

18
by: Philipp Lenssen | last post by:
TinyURL and similar services, as you may know, let users create a short URL out of a long URL. Most people use it in newsgroups or emails only, others use it on Web pages. I find TinyURL has the...
7
by: Tim T | last post by:
Hi, I have the need to use dynamically loaded user controls in a webform page. I have the controls loading dynamically, and that part works fine. this is the code used in a webform to dynamically...
8
by: Donald Xie | last post by:
Hi, I noticed an interesting effect when working with controls that are dynamically loaded. For instance, on a web form with a PlaceHolder control named ImageHolder, I dynamically add an image...
1
by: Kamal Jeet Singh | last post by:
Hi Friends !! I am facing problem in controlling the dynamically created controls on web page. The problem Scenario is Scenario:- My requirement is to load the web user controls on the web...
1
by: Reza Nabi | last post by:
Bakground: I have a webform (LoadCtl.aspx) which loads the user control to a placeholder dynamically based on the ctlName querystring passed in the URL. Webform (LoadCtl.aspx) also passes a...
7
by: pmclinn | last post by:
I was wondering if it is possible to dynamically create a structure. Something like this: public sub main sql = "Select Col1, Col2 from Table a" dim al as new arraylist al =...
9
by: netasp | last post by:
hi all, how can I populate one aspx form when page is loading based on page ID? for example: loading page A (to search for VB code) would display labels and texboxes, dropdown lists all related...
4
by: mohaaron | last post by:
I can think of a lot of reasons why this might need to be done but as far as I can tell it's not possible. I've been looking for a way to add HtmlTableRows to a table using a button click for a...
7
by: RichB | last post by:
I am trying to get to grips with the asp.net ajaxcontrol toolkit, and am trying to add a tabbed control to the page. I have no problems within the aspx file, and can dynamically manipulate a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.