Instagram\Instagram::login PHP Method

login() public method

Login to Instagram with Credentials
public login ( $username, $password ) : LoginResponse
$username string Instagram Username
$password string Instagram Password
return Instagram\API\Response\LoginResponse
    public function login($username, $password)
    {
        $this->setupAsNewDevice();
        $this->setDeviceId($this->generateDeviceId(md5($username . $password)));
        $request = new LoginRequest($this, $username, $password);
        $response = $request->execute();
        if (!$response->isOk()) {
            if ($response->isCheckpointRequired()) {
                throw new InstagramException(sprintf("Login Failed: [%s] %s\nGo to this URL in your web browser to continue:\n%s", $response->getStatus(), $response->getMessage(), $response->getCheckpointUrl()));
            }
            throw new InstagramException(sprintf("Login Failed: [%s] %s", $response->getStatus(), $response->getMessage()));
        }
        $this->setLoggedInUser($response->getLoggedInUser());
        return $response;
    }

Usage Example

Beispiel #1
0
<?php

use instagram\Instagram;
require dirname(__FILE__) . '/src/Instagram.php';
$instagram = new Instagram(['name' => 'value']);
$instagram->login('basic');
#$instagram->auth('code');
#$instagram->search('tag');
#$instagram->follow('user-id');
#$instagram->likeMedia('media-id');
#$instagram->commentMedia('media-id', 'comment');