Interface class for the Shareaholic service.
More...
|
def | __init__ (self, Cloudstorage cloud, on_upload=None, on_clipboard_write=None, on_prepare_url=None, stop_check=None, timeout=5000) |
|
def | share (self, file_or_url, social='twitter', title='My new crossword', notes=_('See my new crossword'), url_shortener='shrlc', tags='pycrossword, crossword, python', source='pycrossword') |
| Shares a given URL or file in selected social networks. More...
|
|
|
string | APPID = 'abf1b67f10817416ba9fee9b76455bef' |
| ID of pycrossword app on Shareaholic. More...
|
|
string | BASEURL = 'https://www.shareaholic.com/api/share/?v=1&apitype=1' |
| base URL for Shareaholic API requests More...
|
|
dictionary | ERRMAP = {'message': 'data', 'code': 'code'} |
| error message key map More...
|
|
dictionary | SERVICES |
| enabled social networks and their Shareaholic internal numbers More...
|
|
Interface class for the Shareaholic service.
The application has a free account on Shareaholic to enable social sharing, i.e. posting text / URLs to your Twitter, Facebook and other social networks.
- See also
- Shareaholic Share API docs
◆ __init__()
def pycross.utils.onlineservices.Share.__init__ |
( |
|
self, |
|
|
Cloudstorage |
cloud, |
|
|
|
on_upload = None , |
|
|
|
on_clipboard_write = None , |
|
|
|
on_prepare_url = None , |
|
|
|
stop_check = None , |
|
|
|
timeout = 5000 |
|
) |
| |
- Parameters
-
cloud | Cloudstorage pointer to a Cloudstorage object |
on_upload | callable function called when a file is uploaded to the cloud storage; takes to args:
str full path to the uploaded file
str generated public link (URL)
|
on_clipboard_write | callable callback called when data is written to the system clipboard (as one sharing option); takes one arg: str generated public link (URL) |
on_prepare_url | callable callback called when the request URL to Shareaholic is prepared; takes one arg: str the request URL |
stop_check | callable callback that takes no arguments and returns True to stop the current sharing operation or False to continue |
timeout | int network request timeout (in msec) |
◆ share()
def pycross.utils.onlineservices.Share.share |
( |
|
self, |
|
|
|
file_or_url, |
|
|
|
social = 'twitter' , |
|
|
|
title = 'My new crossword' , |
|
|
|
notes = _('See my new crossword') , |
|
|
|
url_shortener = 'shrlc' , |
|
|
|
tags = 'pycrossword,crossword,python' , |
|
|
|
source = 'pycrossword' |
|
) |
| |
Shares a given URL or file in selected social networks.
This method is the main interface for the application, since it encapsulates the lower-level cloud storage functionality to upload files and create public links.
- Warning
- This method is called in a separate thread, so it is designed for maximum thread safety. That is also the reason why it doesn't return any results but rather replies on callback functions.
- Parameters
-
file_or_url | str full path to a local file or a prepared link (URL) |
social | str social network short name, e.g. 'twitter' – see Share::SERVICES |
title | str title (caption) for your post |
notes | str message body for your post |
url_shortener | str URL shortening service to shorten your link URL; see Shareaholic docs for available options |
tags | str comma-separated tags for your post |
source | str name of the sharing app ('pycrossword') |
◆ APPID
string pycross.utils.onlineservices.Share.APPID = 'abf1b67f10817416ba9fee9b76455bef' |
|
static |
ID of pycrossword app on Shareaholic.
◆ BASEURL
string pycross.utils.onlineservices.Share.BASEURL = 'https://www.shareaholic.com/api/share/?v=1&apitype=1' |
|
static |
base URL for Shareaholic API requests
◆ cloud
pycross.utils.onlineservices.Share.cloud |
◆ ERRMAP
dictionary pycross.utils.onlineservices.Share.ERRMAP = {'message': 'data', 'code': 'code'} |
|
static |
◆ on_clipboard_write
pycross.utils.onlineservices.Share.on_clipboard_write |
callable
callback called when data is written to the system clipboard (as one sharing option)
◆ on_prepare_url
pycross.utils.onlineservices.Share.on_prepare_url |
callable
callback called when the request URL to Shareaholic is prepared
◆ on_upload
pycross.utils.onlineservices.Share.on_upload |
callable
function called when a file is uploaded
◆ SERVICES
dictionary pycross.utils.onlineservices.Share.SERVICES |
|
static |
Initial value:= {'twitter': 7, 'facebook': 5, 'pinterest': 309, 'linkedin': 88, 'gmail': 52,
'yahoomail': 54, 'aolmail': 55, 'hotmail': 53, 'myspace': 39,
'reddit': 40, 'skype': 989, 'tumblr': 78, 'yandex': 267, 'clipboard': 0}
enabled social networks and their Shareaholic internal numbers
◆ stop_check
pycross.utils.onlineservices.Share.stop_check |
callable
callback that takes no arguments and returns True
to stop the current sharing operation or False
to continue
◆ timeout
pycross.utils.onlineservices.Share.timeout |
int
network request timeout (in msec)
The documentation for this class was generated from the following file: