sharasolns/link-shortener

There is no license information available for the latest version (dev-main) of this package.

Link shortener for php

dev-main 2024-01-24 06:22 UTC

This package is auto-updated.

Last update: 2024-05-24 06:56:23 UTC


README

Php package to easily shorten your links from https://sm.ke.

Installation

Using composer, install it with the following command

composer require sharasolns/link-shortener

Authentication

You need an api key to use this package, procedure

  • Login to your sm account here https://app.sm.ke
  • Go to Profile > Settings > ApiKeys or click this link if you are logged in https://app.sm.ke/settings/tab/api-keys
  • Click Add Key, give it a name then submit
  • You will be prompted to copy the api key You are done with generating api key, use it in the step below

Usage

To use it, in plain php, below is the code structure

$apikey = "Your_Api_ Key";

$shortener = new \Sharasolns\LinkShortener\Links\Shortener($apikey);
$longUrl = "https://example.com/long-url";
$res = $shortener->shortenLink($url);

$shortenedUrl = $res->link->shortened_url