/
Login.php
47 lines (39 loc) · 1.3 KB
/
Login.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
/**
* @category Instagram
* @package Instagram_Command
* @copyright Copyright (c) 2010-2011 Matthias Steinböck <matthias@abendstille.at>
* @license New BSD License (enclosed file docs/LICENSE)
*/
class Instagram_Command_Login extends Instagram_Command_AbstractCommand
{
protected $_requires = array(
'username',
'device_id',
'password'
);
public function exec() {
$postdata = array(
'username'=> $this->_parameters['username'],
'device_id' => $this->_parameters['device_id'],
'password' => $this->_parameters['password']
);
$client = $this->_communication->getClient();
$client->setUri('http://instagr.am/api/v1/accounts/login/');
$client->setHeaders(array(
'User-Agent' => 'Instagram 1.9.4 (iPhone; iPhone OS 4.0.1; de_AT)',
'Content-Type' => 'application/x-www-form-urlencoded; charset=utf-8',
'Accept-Encoding' => 'gzip'
// 'Connection' => 'keep-alive'
));
$client->setParameterPost($postdata);
$response = $client->request(Zend_Http_Client::POST);
$success = Instagram_Client_Marshaller::unmarshall($response->getBody(), true);
if ($success->status != 'ok') {
$ex = new Instagram_Command_LoginFailedException($success->message);
$ex->setResponse($response);
throw $ex;
}
$this->getResponse()->setData($success);
}
}