DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Introduction To Template-Based Email Design With Spring Boot
  • From APIs to Actions: Rethinking Back-End Design for Agents
  • Document Generation API: How to Automate Personalized Document Creation at Scale
  • Level Up Your API Design: 8 Principles for World-Class REST APIs

Trending

  • Testing Is Not About Finding Bugs
  • Fix the Target, Precompute Once: A Backend-Free Word-Ladder Solver With a BFS Distance Field
  • Automating Power Automate: How to Ensure Cloud Flows Are Active After Every Pipeline Deployment
  • Mastering Fluent Bit: Beginners' Guide for Contributing to Our CNCF Project Website
  1. DZone
  2. Data Engineering
  3. Databases
  4. Reverse TinyURL

Reverse TinyURL

By 
Logan Koester user avatar
Logan Koester
·
Jul. 02, 07 · Code Snippet
Likes (0)
Comment
Save
Tweet
Share
8.4K Views

Join the DZone community and get the full member experience.

Join For Free
PHP
 
// Resolves a TinyURL.com encoded URL to its source.
// Example: reverse_tinyurl('http://tinyurl.com/2ocfun') => "http://logankoester.com"
function reverse_tinyurl($url) {
    $url = explode('.com/', $url);
    $url = 'http://preview.tinyurl.com/' . $url[1];
    $preview = file_get_contents($url);
    preg_match('/redirecturl" href="(.*)">/', $preview, $matches);
    return $matches[1];
}


API Design Snippet (programming) Template

Opinions expressed by DZone contributors are their own.

Related

  • Introduction To Template-Based Email Design With Spring Boot
  • From APIs to Actions: Rethinking Back-End Design for Agents
  • Document Generation API: How to Automate Personalized Document Creation at Scale
  • Level Up Your API Design: 8 Principles for World-Class REST APIs

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook