ryldz07 / mgp25

İnstagram mgp25 php api
Other
83 stars 82 forks source link

Examples #5

Open haexperts2020 opened 3 years ago

haexperts2020 commented 3 years ago

For anyone trying to use this from the original code, it was taken down by Instagram. Not shock there.

Here is some working code that can get you started:

<?php
include __DIR__.'/vendor/autoload.php';
require_once 'vendor/mgp25/instagram-php/src/Instagram.php'; //might need to update this if your path is different

$username = 'username'; // create a dummy account that we will login using our spoofing script
$password = 'password'; // your password

$i = new \InstagramAPI\Instagram($username, $password, 'false');
$i->login();

Once your login, now you can call functions from the $i object

$user = $i->searchUsername('NBA');
$user_id = $user['user']['pk'];
$feed = $i->getUserFeed($user_id, $maxid = null, $count = null);
var_dump($feed);

From here you can go into the Instagram.php src file and see all the functions available and just pass the appropriate variables to the function to return the object. From there you can parse the data and do something with it. I messed around with this back in 2016 to do some data scaping. Sadly I am sure some use this to abuse and create IG robots.

You might have to comment out a couple lines of code as Instagram has changed their inbox API calls. In the Instagram.php src file goto line 700 and comment out these lines in the inbox function


public function getv2Inbox()
  {
      $inbox = $this->http->request('direct_v2/inbox/?')[1];
      //if ($inbox['status'] != 'ok') {
      //    //throw new InstagramException($inbox['message']."\n");
      //    return;
      //}
      return $inbox;
  }

I know this isn't and issue with the code but if the owner of the account gets this, maybe post it in the readme?