Author Topic: Find my iPhone  (Read 15802 times)

0 Members and 1 Guest are viewing this topic.

Haddood

  • $upporter
  • Hero Member
  • *****
  • Posts: 688
  • Karma: 22
    • View Profile
Find my iPhone
« on: August 03, 2014, 04:59:42 AM »
Reading http://voxcommando.com/forum/index.php?topic=1662.0;topicseen about paging android devices ... Made me jump to google and try to find if apple expose an API for find my phone ... I found this project

https://github.com/comfuture/recordmylatitude/blob/master/findmyiphone/__init__.py

Which is basically python program that hooks up to apple API and give the command available programmatically ...

Since I am python toddler (can do just simple arithmetic only) ... I wish a python savvy help us to adapt the script to work with VC ...

It will be great to tell VC make my phone ring ... To find under which pillow it is !!!!

P.S. The python is ported from this PHP project: https://github.com/tylerhall/sosumi/blob/master/class.sosumi.php


UPDATE: the script in this discussion are no longer working due to changes that apple implemented ... I will update if new solution arise
« Last Edit: January 11, 2015, 02:16:10 AM by Haddood »
When Voice command gets tough, use hand gestures

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Find my iPhone
« Reply #1 on: August 03, 2014, 12:48:52 PM »
Since we don't have Apple products to test the code with, we can't really help.

The code may be usable just as it is (though it may be optimistic to expect it to work out of the box). It does more than you are looking for it to do, but that doesn't really matter.

If you've already enabled your iCloud "find my iphone" service, why don't you try it?

The easiest way to test it is for you to install Python for Windows (it's pretty small): https://www.python.org/downloads/

This is to eliminate any possible complications that Iron Python might add to the mix. If you're able to get the code to work natively, then we can worry about the VC end of things.

1. Save the GitHub file as a .py file on your computer.

2. Run the IDE that comes with Python, called IDLE (just search in your start menu for IDLE and it will appear).

Open the .py file you just saved to your computer in IDLE. Then run it. ("Run Module" or F5)

If you get no errors, then try the next step. You'll need your Apple username and password, as well as the UDID for your iPhone.

In IDLE, type:
pageMe=FindMyIPhone('[yourusername]','[yourpassword]')

If *that* works, and you don't getting any authentication errors or anything, then wonder of wonder. You're ready to try paging yourself.

So then, try one of the functions in that module. Again, in IDLE, enter:

pageMe.locate('[yourUDID]')

No errors? (Wow!) OK, try sending yourself a message then.

pageMe.sendMessage('Your Message', True, '[UDID]', 'Important Message')

...I *think* the true should trigger the alarm sound. The 1st stuff in quotes is supposed to be the message that you get. The last string is the subject line.

It's a long shot, but if you have the time, why not?


« Last Edit: August 03, 2014, 01:03:34 PM by nime5ter »
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

Haddood

  • $upporter
  • Hero Member
  • *****
  • Posts: 688
  • Karma: 22
    • View Profile
Re: Find my iPhone
« Reply #2 on: August 03, 2014, 01:01:53 PM »
thank you nime5ter will do that and post the results ....
When Voice command gets tough, use hand gestures

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Find my iPhone
« Reply #3 on: August 03, 2014, 03:04:59 PM »
I have exciting news for you. This code works as is with Iron Python no problem. At least, it works with the 5-year-old iPod I have -- the only thing I had to test it with.

I was wrong about needing your UDID. The code actually finds the UDIDs for all of the Apple devices associated with your iCloud account internally.

So, if you have just one device, then the following will work as is, otherwise, you may have to make slight adjustments which we can discuss when relevant:

2 VC commands are easy. Load the py file. Call the python when you want to page your phone. Enter your iCloud username and pwd in the command where indicated.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.0.0.5-->
<commandGroup open="True" name="iphone pager" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="299" name="ipager" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>PY.ExecString</cmdType>
      <params>
        <param>pager("[yourusername]","[yourpwd]")</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>Where is my eye phone?</phrase>
  </command>
  <command id="304" name="load python" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>PY.ExecFile</cmdType>
      <params>
        <param>PY\iphonePager.py</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <event>VC.Loaded</event>
  </command>
</commandGroup>

Put the attached file in your VoxCommando \PY directory ... or change the file path in the command, as per usual.
« Last Edit: August 03, 2014, 03:31:04 PM by nime5ter »
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

Haddood

  • $upporter
  • Hero Member
  • *****
  • Posts: 688
  • Karma: 22
    • View Profile
Re: Find my iPhone
« Reply #4 on: August 03, 2014, 09:15:50 PM »
 :clap :clap :clap :yay :yay :yay ::bow ::bow ::bow

this is amazing news for all iPhoners, iPaders and iPoders and iMac-ers who use VC

I modified your Pager function to include device ID ... as I have and iPad as well ...

Following your example (pager) I added ... remote lock and will do some testing with locate, maybe passing the coordinate to a mapping site that gives the address ... so one says "where is my phone" VC will respond: it is at work, home ... or 1660 Boulvard St-Laurant ... etc.

as well for the fun one can add: "VC initiate self-destruction on my iPhone", VC: "Enter self-destruction sequence code" ..."1234", "Are you sure?" "yes" "are you really sure" ..... "Damn it, destroy the thing" and that will wipe remotely the phone !!!

Again a million thank you
« Last Edit: August 03, 2014, 10:07:51 PM by Haddood »
When Voice command gets tough, use hand gestures

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2320
  • Karma: 47
    • View Profile
Re: Find my iPhone
« Reply #5 on: August 04, 2014, 01:24:58 AM »
Hi Haddood, please can you explain step by step how you did get it to work.

Thanks
Kalle
***********  get excited and make things  **********

Haddood

  • $upporter
  • Hero Member
  • *****
  • Posts: 688
  • Karma: 22
    • View Profile
Re: Find my iPhone
« Reply #6 on: August 04, 2014, 02:15:05 PM »
Hi Kalle ...
late reply due to time differences

there is not much require explanation ...
just place the Python script in PY folder in voxcommando (I am attaching the modified one) then you can call

PY.ExecString iPager("icloud user name usualy email","icloud password", deviceID)
PY.ExecString iLock("icloud user name usualy email","icloud password", deviceID, PassCode)

Device ID is an integer starting with 0, the sequence is the same  ... if you are not sure which is which start iPager with 0 and increment and see which device rings ...
PassCode in the iLock has no effect ifyou already have a passcode enabled ... otherwise PassCode will be the new setting ...

as for iLocate & iWipe ... I have not enabled these functions yet ... iWipe is pretty easy to set, the only problem I do not have a device that I can afford wiping ... iLocate will require some research for mapping services to display the coordinates

hope that helps
When Voice command gets tough, use hand gestures

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2320
  • Karma: 47
    • View Profile
Re: Find my iPhone
« Reply #7 on: August 04, 2014, 02:36:12 PM »
Big Thanks  ::bow
***********  get excited and make things  **********

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Find my iPhone
« Reply #8 on: August 04, 2014, 03:28:54 PM »
Quote
. iLocate will require some research for mapping services to display the coordinates

You can probably us a Google map URL.  They look like this

https://www.google.ca/maps/@{latitude},{longitude},11z

so if the python returns some kind of lat/long variables it should be pretty easy with Launch.URL

Haddood

  • $upporter
  • Hero Member
  • *****
  • Posts: 688
  • Karma: 22
    • View Profile
Re: Find my iPhone
« Reply #9 on: August 04, 2014, 04:41:19 PM »
James ...

You can probably us a Google map URL.  They look like this

https://www.google.ca/maps/@{latitude},{longitude},11z

so if the python returns some kind of lat/long variables it should be pretty easy with Launch.URL

just figured that out ... this morning after few tests ....

however I am having trouble returning the location back to VC ... this is the command I added to the script above ...

Code: [Select]
def iLocate(username,password,device_num, max_wait):
    myP=FindMyIPhone(username,password)
    strLocation = myP.locate(device_num, max_wait)

however if I try :
Code: [Select]
return strLocation the python script do not load giving errors

I tried even:
Code: [Select]
vc.triggerEvent("iCloud.Locate", List[str]([strLocation]))

again script do not load giving errors ...

I have no idea what I am doing ... just copying and trial and error with your examples and nime5ter examples ... any help appreciated
When Voice command gets tough, use hand gestures

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Find my iPhone
« Reply #10 on: August 04, 2014, 05:09:44 PM »
if you look at the locate method, you will see that it does not return a string.  here is what it returns:
Code: [Select]
       return {
            'latitude': device.latitude,
            'longitude': device.longitude,
            'accuracy': device.horizontal_accuracy,
            'timestamp': device.location_timestamp,
       }

so you will need to do something like:
Code: [Select]
def iLocate(username,password,device_num, max_wait):
    myP=FindMyIPhone(username,password)
    locData = myP.locate(device_num, max_wait)
    strUrl = 'https://www.google.ca/maps/@'+locData.latitude +','+ locData.longitude +',11z'
    vc.callAction("Launch.OpenURL",strUrl, None)


nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Find my iPhone
« Reply #11 on: August 04, 2014, 05:16:39 PM »
James posted the above without testing it. The following actually works:

Code: [Select]

def iLocate(username,password,device_num):
    myP=FindMyIPhone(username,password)
    locData = myP.locate(device_num)
    strUrl = 'https://www.google.ca/maps/@'+str(locData['latitude']) +','+ str(locData['longitude']) +',12z'
    vc.callAction("Launch.OpenURL",strUrl, None)
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

Haddood

  • $upporter
  • Hero Member
  • *****
  • Posts: 688
  • Karma: 22
    • View Profile
Re: Find my iPhone
« Reply #12 on: August 04, 2014, 05:47:56 PM »
That is great .... thank you, thank you, thank you,  ;D ;D

one more questions:  can we return the location back to VC and lunch the URL from within command builder ... as  we can do much more than just lunch maps ... e.x. we can use that to ping the phone geo-data every few minutes to know when someone getting close to home, work ...etc.
When Voice command gets tough, use hand gestures

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Find my iPhone
« Reply #13 on: August 04, 2014, 06:00:30 PM »
Yes, sure. One way is:

Code: [Select]
from System.Collections.Generic import *

def iLocate(username,password,device_num):
    myP=FindMyIPhone(username,password)
    locData = myP.locate(device_num)
    #strUrl = 'https://maps.google.ca/maps?q='+str(locData['latitude']) +','+ str(locData['longitude'])
    #vc.callAction("Launch.OpenURL",strUrl, None)
    vc.triggerEvent("locData", List[str]([str(locData['latitude']),str(locData['longitude'])]))

This would trigger an event called locData, passing latitude as {1} and longitude as {2}.

By the way, in my code here I've commented out an alternate Google Maps URL that I like better than the one posted above, because it includes a location marker on the map.
« Last Edit: August 04, 2014, 06:05:47 PM by nime5ter »
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Find my iPhone
« Reply #14 on: August 04, 2014, 06:02:57 PM »
Remember that if you want to trigger an event that takes payloads, you always need the:

Code: [Select]
from System.Collections.Generic import *
http://voxcommando.com/mediawiki/index.php?title=Python#Triggering_an_Event
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)