Now the same team have been working on a Soviet-era clock from a Soyuz spacecraft.
The clock is in pretty good condition, so won’t take the time and effort it took to restore the AGC, but for the electronic and space geeks, this is pretty cool too.
I will add to this playlist as more installments of their work is added.
Recently Bitly have rolled out version 4 of their API, and if you’re using the old API, it is quite a change.
While users were asked to move from older versions to the new version before March 1st 2020, the version 3 API was to hang around until March 31st 2020 to give people a little extra time to move.
Given the current COVID-19 situation, this discontinuation has been put on hold for the time being as per an email sent out to API users.
Nevertheless, it is absolutely time to move to the new version to ensure that you can still automate the shortening of your URLs.
Given my professional working life, I’ve worked with very similar API implementations, so for me it wasn’t a big deal to change over.
Here is the simple function I wrote for PHP, to do a basic URL shorten. Your PHP installation will need to have cURL and JSON libraries installed and enabled.
$access_token – this is the same as your existing OAuth application access token – this has not changed, at least in my case.
$group_guid – this is the only new piece of information you might need. While you can query for this value via the API, for most people the simplest way to get it is to open into your Bitly account in a web browser, where you will find the GUID in the URL, as per this image:
$shorten_domain – if you have a custom domain – (for example, I have the domain “mwyr.es” for shortening purposes) – this is the value you need here. If you don’t have a custom domain, just use “bit.ly”.
$shorten_url – this is the URL you wish to shorten – simple!
So now you can call the function, with the required information.
Firstly, the input data required by the API is converted to JSON via the json_encode() function.
Secondly, we set up the cURL handle, and then supply it with the required data. Note the JSON data is passed within the “CURLOPT_POSTFIELDS” variable, and that the access token is passed as the “Authorization: Bearer” header in the “CURLOPT_HTTPHEADER” variable.
Then we execute with curl_exec() – and store and return the results for further processing.
That’s it!
To understand the returned JSON – (including the generated short link) – and the HTTP response codes, refer to the excellent Bitly API v4 documentation.