def store_location():
    "Fetches an iPhone location from the Apple API and creates a Location Object"
    iphone = FindMyIPhone(APPLE_EMAIL, APPLE_PASSWORD)
    iphone_location = iphone.locate()

    location = Location()
    location.latitude = iphone_location.get('latitude')
    location.longitude = iphone_location.get('longitude')
    db.add(location)
    # Persist to the database
    db.commit()
    return location
Exemplo n.º 2
0
import os
from findi import FindMyIPhone

# be careful storing your personal apple id in files. In this case we make it an environment variable

APPLE_EMAIL = os.environ.get("APPLE_EMAIL")
APPLE_PASSWORD = os.environ.get("APPLE_PASSWORD")

# initialize findmyiphone with your apple ID

iphone = FindMyIPhone(APPLE_EMAIL, APPLE_PASSWORD)

# locate the iphone

iphone_location = iphone.locate()

# iphone.locate() returns a dictionary that contains a latitude and longitude

latitude = iphone_location.get('latitude')
longitude = iphone_location.get('longitude')

print latitude, longitude