Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Login request
- $sRequestUrl = 'http://MYURL/w/api.php?action=query&meta=tokens&type=login&format=json';
- $oResponse = Request::post($sRequestUrl)
- ->addHeader('User-Agent', 'MYUSERAGENT')
- ->expectsJson()
- ->send();
- $sLoginToken = $oResponse->body->query->tokens->logintoken;
- $oHeader = current($oResponse->headers);
- $sCookie = $oHeader['set-cookie'];
- // Login confirm
- $sRequestUrl = 'http://MYURL/w/api.php?action=login&format=json';
- $aBodyData = array(
- 'lgname' => 'MYUSER@MYBOT',
- 'lgpassword' => 'MYBOTPASSWORD',
- 'lgtoken' => $sLoginToken
- );
- $oResponse = Request::post($sRequestUrl)
- ->addHeader('User-Agent', 'MYUSERAGENT')
- ->addHeader('Cookie', $sCookie)
- ->expectsJson()
- ->body(http_build_query($aBodyData))
- ->send();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement