Page MenuHomePhabricator

Use another URL shortener in Wikidata Query GUI
Closed, DuplicatePublic

Description

tinyurl.com is blocked to prevent spam in most Wikimedia wikis (including Wikidata) so it's not possible to link to a shortened query from Wikidata discussions.

How about storing the shortened queries in a database as part of the Wikidata Query Service (e.g. https://query.wikidata.org/x/SHORTCODE)? This could be extended to a public list of sample queries.

Event Timeline

Restricted Application added subscribers: Zppix, Aklapper. · View Herald Transcript
Bhumika30 subscribed.

Hi,

Another option of tinyurl.com can be https://goo.gl/.Which is google's application.With the use of google.gl You can see how many people have clicked on your URL by visiting goo.gl.

It is easy to implement also:

  1. Visit the Google URL shortener site at goo.gl.
  2. If you aren’t signed in, click the Sign in button in the top right corner.
  3. Write or paste your URL in the Paste your long URL here box.
  4. Click Shorten URL.

Or we can integrate this API to any platform.

Below is script to use it with PHP:

Place your API Key,created from your account
<?php
Url to shorten
$longUrl = 'http://www.learn-drupal.in';
$apiKey = 'Your Api key here';
You can get API key here : Login to google and
go to http://code.google.com/apis/console/
Find API key under credentials under APIs & auth.
You will need to do necessary things to get key there. :)
Watch video below.

// * No need to modify any of the code line below. *
$postData = array('longUrl' => $longUrl, 'key' => $apiKey);
$jsonData = json_encode($postData);
$curlObj = curl_init();
curl_setopt($curlObj, CURLOPT_URL, 'https://www.googleapis.com/urlshortener/v1/url?key='.$apiKey);
curl_setopt($curlObj, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curlObj, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curlObj, CURLOPT_HEADER, 0);
curl_setopt($curlObj, CURLOPT_HTTPHEADER, array('Content-type:application/json'));
curl_setopt($curlObj, CURLOPT_POST, 1);
curl_setopt($curlObj, CURLOPT_POSTFIELDS, $jsonData);
$response = curl_exec($curlObj);
$json = json_decode($response);

curl_close($curlObj);
echo 'Shortened URL ->'.$json->id;
?>

Thanks,
Bhumika Brahmbhatt