From b249554119bbdca20437316b50b0f3cdb2238a6a Mon Sep 17 00:00:00 2001 From: Peter Evans Date: Tue, 1 Jan 2013 16:30:35 +0000 Subject: [PATCH] Adding the Find My iPhone 'lost mode' method. --- services/findmyiphone.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) mode change 100644 => 100755 services/findmyiphone.py diff --git a/services/findmyiphone.py b/services/findmyiphone.py old mode 100644 new mode 100755 index 3be69ff..72155b6 --- a/services/findmyiphone.py +++ b/services/findmyiphone.py @@ -15,6 +15,7 @@ class FindMyiPhoneService(object): self._fmip_endpoint = '%s/fmipservice/client/web' % self._service_root self._fmip_refresh_url = '%s/refreshClient' % self._fmip_endpoint self._fmip_sound_url = '%s/playSound' % self._fmip_endpoint + self._fmip_lost_url = '%s/lostDevice' % self._fmip_endpoint def refresh_client(self): """ @@ -58,3 +59,23 @@ class FindMyiPhoneService(object): self.refresh_client() data = json.dumps({'device': self.content['id'], 'subject': subject}) self.session.post(self._fmip_sound_url, params=self.params, data=data) + + def lost_device(self, number, text=None): + """ + Send a request to the device to trigger 'lost mode'. The + device will show the message in `text`, and if a number has + been passed, then the person holding the device can call + the number without entering the passcode. + """ + self.refresh_client() + if not text: + text = 'This iPhone has been lost. Please call me.' + data = json.dumps({ + 'text': text, + 'userText': True, + 'ownerNbr': number, + 'lostModeEnabled': True, + 'trackingEnabled': True, + 'device': self.content['id'], + }) + self.session.post(self._fmip_lost_url, params=self.params, data=data)