A
A
Aibek Zhaksybaev2018-04-30 08:19:50
PHP
Aibek Zhaksybaev, 2018-04-30 08:19:50

Why doesn't getCodeFromId Instagram work?

Hello everyone, when parsing data about a post in instagram, an instagram post id of type 1768009994382509677 is sent, there is a function that converts it into a shortcode of type BiJO7j6goZt
function code:

function getCodeFromId($id)
{
    $parts = explode('_', $id);
    $id = $parts[0];
    $alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_';
    $shortenedId = '';
    while ($id > 0) {
        $remainder = $id % 64;
        $id = ($id - $remainder) / 64;
        $shortenedId = $alphabet{$remainder} . $shortenedId;
    };
    return $shortenedId;
}

But when converting, it gives out not at all what is needed, such as BiJO7k6hpY_, but it should be BiJO7j6goZt, what should I do?
With BiJO7k6hpY_ :
5ae6a72550723036650248.jpeg
And with BiJO7j6goZt :
5ae6a763501af416927888.jpeg

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question