adiv-phpian / php-instagram-private-api-with-checkpoint-feature

This is a liam cottle instagram private library with checkpoint issue solved. Checkpoint required error solved and can be found at examples folder.
MIT License
12 stars 8 forks source link

how to use this library in mgp25/Instagram-API #3

Open hosseinab opened 6 years ago

hosseinab commented 6 years ago

hi . Is there a way to use this way in the mgp25/Instagram-API library for checkpoint? best regards

adiv-phpian commented 6 years ago

Yes, it's possible. If you can able to integrate two functions. sending verification code and confirming verification code. or you can save cookies on cookie jar from this library and use it with mgp25. Make sure you use correct file name structure according to mgp25 and location too.

hosseinab commented 6 years ago

Do you have a sample code for this ?

hosseinab commented 6 years ago

When I send the activation code to the server and receive a response to the correct code. What should I do to save the session? (in mgp25 library)

adiv-phpian commented 6 years ago

I will provide a sample if I create one in future for mgp25.

hosseinab commented 6 years ago

hi I wrote these three functions for mgp25 library :

1- function for send get to checkpoint url :

` public function checkpoint( $url ,$appRefreshInterval = 1800) { if (empty($url)) { throw new \InvalidArgumentException("You must provide a url to checkpoint."); }

    try {
        $response = $this->request($url)
            ->setNeedsAuth(false)
            ->getRawResponse();

    } catch (\InstagramAPI\Exception\InstagramException $e) {
        functions::dd($e->getMessage());
        return $e->getMessage();
    }

    return $response;
}`

2- function for select verification method and send code ` public function sendVerificationCode( $url, $method) { if (empty($url)) { throw new \InvalidArgumentException("You must provide a url to checkpoint."); }

    try {

        $token = $this->client->getToken();

        $response = $this->request($url)
            ->setNeedsAuth(false)
            ->addHeader("x-instagram-ajax" , true)
            ->addHeader("referer" , $url)
            ->addHeader('x-csrftoken', $token)
            ->addParam("choice", $method)
            ->addPost("choice", $method)
            ->addUnsignedPost("choice", $method)
            ->getResponse(new Response\LoginResponse());

        \Yii::$app->session->set('cookie', $token);

    } catch (\InstagramAPI\Exception\InstagramException $e) {
        functions::dd($e->getMessage());
        return $e->getMessage();
    }
    return $response;
}

3- function for send code public function ConfirmVerificationCode( $url, $code) { if (empty($url)) { throw new \InvalidArgumentException("You must provide a url to checkpoint."); }

    try {

        $response = $this->request($url)
            ->setNeedsAuth(false)
            ->addHeader("x-instagram-ajax" , true)
            ->addHeader("referer" , $url)
            ->addHeader("x-csrftoken", \Yii::$app->session->get('cookie'))
            ->addParam("security_code", $code)
            ->addPost("security_code", $code)
            ->addUnsignedPost("security_code", $code)
            ->getRawResponse();

    } catch (\InstagramAPI\Exception\InstagramException $e) {
        functions::dd($e->getMessage());
        exit();
        return $e->getMessage();
    }

    functions::dd($response);
    return $response;
}`

function 1 and 2 works correct , but three function not get correct response : '{\"message\": \"\", \"challenge\": {\"challengeType\": \"SelectVerificationMethodForm\", \"errors\": [\"This field is required.\"], \"experiments\": {}, \"extraData\": {\"__typename\": \"GraphChallengePage\", \"content\": [{\"__typename\": \"GraphChallengePageBanner\", \"banner_text\": \"Suspicious Login Attempt\"}, {\"__typename\": \"GraphChallengePageHeader\", \"description\": null, \"title\": \"We Detected An Unusual Login Attempt\"}, {\"__typename\": \"GraphChallengePageText\", \"alignment\": \"center\", \"html\": null, \"text\": \"To secure your account, we\'ll send you a security code to verify your identity. How do you want to receive your code?\"}, {\"__typename\": \"GraphChallengePageForm\", \"call_to_action\": \"Send Security Code\", \"display\": \"inline\", \"fields\": [{\"__typename\": \"GraphChallengePageFormChoiceField\", \"input_name\": \"choice\", \"input_type\": \"choice\", \"values\": [{\"label\": \"Email: k****s@i*****.ir\", \"selected\": true, \"value\": 1}, {\"label\": \"Phone: +98 *** *** **41\", \"selected\": false, \"value\": 0}]}], \"href\": null}]}, \"fields\": {\"choice\": \"1\", \"fb_access_token\": \"None\", \"big_blue_token\": \"None\", \"google_oauth_token\": \"true\", \"email\": \"k****s@i*****.ir\", \"phone_number\": \"+98 *** *** **41\"}, \"navigation\": {\"forward\": \"/challenge/5591131890/D0CXOE8hwi/\", \"replay\": \"/challenge/replay/5591131890/D0CXOE8hwi/\", \"dismiss\": \"instagram://checkpoint/dismiss\"}, \"privacyPolicyUrl\": \"/about/legal/privacy/\", \"type\": \"CHALLENGE\"}, \"status\": \"fail\"}'

please help me . thanks

adiv-phpian commented 6 years ago

You need to save cookies from first step and use it on second, third step.

hosseinab commented 6 years ago

thanks for answer . save the cookies in step 2 in session : \Yii::$app->session->set('cookie', $token);

read the cookies in step 3 : ->addHeader("x-csrftoken", \Yii::$app->session->get('cookie'))

adiv-phpian commented 6 years ago

you need to save cookies on cookie jar when using curl.

hosseinab commented 6 years ago

What to do? please help me to save cookies

hosseinab commented 6 years ago

Sorry, did not create this sample?

htnlabs commented 6 years ago

Very good. Wait

hosseinab commented 6 years ago

plz help me

adiv-phpian commented 6 years ago

Hi, @hosseinab I don't have the example for mgp25. if I create one, I will post an update. Please see the example, understand the flow. You can apply flow on Yii.

adiv-phpian commented 6 years ago

Hi @hosseinab , you will get all you want from this library and it's suitable for mgp25.

https://github.com/danleyb2/Instagram-API-php

composer require mgp25/instagram-php dev-master

hosseinab commented 6 years ago

This is old version. I want a new version of this library. thanks

adiv-phpian commented 6 years ago

Use the dev-master when you pull mgp25

On Thu, 5 Jul 2018, 13:00 hossein ahmadzadeh, notifications@github.com wrote:

This is old version. I want a new version of this library. thanks

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/muthu-kc/php-instagram-private-api-with-checkpoint-feature/issues/3#issuecomment-402631079, or mute the thread https://github.com/notifications/unsubscribe-auth/AHjnGNtkq6raqY1OGfBt93t_8wMGMsdpks5uDcCSgaJpZM4UejUc .

hosseinab commented 6 years ago

i use dev master . I do not understand what you mean

uigormarshall commented 5 years ago

Hello! I would like to do this in mgp25, could you help me?

adiv-phpian commented 5 years ago

I am working on mgp25 checkpoint issue. I will update once it's done.

luancaike commented 5 years ago

I'm interested in using mgp25 but the checkpoint problem in it for me is still a problem.

vasilywang commented 5 years ago

@muthu-kc any good news?

adiv-phpian commented 5 years ago

Hello Guys, I have been working on mgp25 for almost two days and I wrote a class for mgp25 to solve checkpoint issue. It's working and have to make minor changes I will test it and post an update here. Anybuddy willing to get paid version?

nubinter commented 5 years ago

Please help us share the mgp25 version

adiv-phpian commented 5 years ago

mgp25 version https://github.com/muthu-kc/instagram-checkpoint-and-rate-limit

pishguy commented 4 years ago

@muthu-kc how can i solve mgp25 repository?