-
Notifications
You must be signed in to change notification settings - Fork 33
/
oauth_test_4.py
executable file
·36 lines (26 loc) · 1.14 KB
/
oauth_test_4.py
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
#!/usr/bin/env python
import logging
logging.basicConfig(level=logging.DEBUG)
logging.getLogger('requests_oauthlib').setLevel(logging.INFO)
logging.getLogger('oauthlib').setLevel(logging.INFO)
from flickrapi import FlickrAPI
class keys:
apikey = u'a233c66549c9fb5e40a68c1ae156b370'
apisecret = u'03fbb3ea705fe096'
print('Creating FlickrAPI object')
flickr = FlickrAPI(keys.apikey, keys.apisecret)
# ------------------------------------------------------------------------------
print('Step 1: authenticate')
flickr.authenticate_via_browser(perms='delete')
# ------------------------------------------------------------------------------
print('Step 2: Upload photo')
resp = flickr.upload('tests/photo.jpg', is_public=0, is_friend=0, is_family=0)
from xml.etree import ElementTree as ET
ET.dump(resp)
photo_id = resp.findtext('photoid')
# ------------------------------------------------------------------------------
print('Step 3: Replace photo')
flickr.replace('jaguar.jpg', photo_id=photo_id)
# ------------------------------------------------------------------------------
print('Step 4: Delete photo')
flickr.photos.delete(photo_id=photo_id)