forked from friendica/friendica-addons
Compare commits
6 commits
efdc4fa3c0
...
9732ad543b
Author | SHA1 | Date | |
---|---|---|---|
Hypolite Petovan | 9732ad543b | ||
Michael | 37cdd74d73 | ||
Hypolite Petovan | c1830d8fd1 | ||
Michael | 7dc1b44d1e | ||
Hypolite Petovan | 94129d3aa5 | ||
Tobias Diekershoff | 5ea5930d82 |
266
.tx/config
266
.tx/config
|
@ -1,399 +1,399 @@
|
|||
[main]
|
||||
host = https://www.transifex.com
|
||||
host = https://api.transifex.com
|
||||
|
||||
[friendica.addon_advancedcontentfilter_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_advancedcontentfilter_messagespo]
|
||||
file_filter = advancedcontentfilter/lang/<lang>/messages.po
|
||||
source_file = advancedcontentfilter/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_blackout_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_blackout_messagespo]
|
||||
file_filter = blackout/lang/<lang>/messages.po
|
||||
source_file = blackout/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_blockem_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_blockem_messagespo]
|
||||
file_filter = blockem/lang/<lang>/messages.po
|
||||
source_file = blockem/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_blogger_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_blogger_messagespo]
|
||||
file_filter = blogger/lang/<lang>/messages.po
|
||||
source_file = blogger/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_buffer_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_buffer_messagespo]
|
||||
file_filter = buffer/lang/<lang>/messages.po
|
||||
source_file = buffer/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_buglink_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_buglink_messagespo]
|
||||
file_filter = buglink/lang/<lang>/messages.po
|
||||
source_file = buglink/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_catavatar_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_catavatar_messagespo]
|
||||
file_filter = catavatar/lang/<lang>/messages.po
|
||||
source_file = catavatar/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_cookienotice_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_cookienotice_messagespo]
|
||||
file_filter = cookienotice/lang/<lang>/messages.po
|
||||
source_file = cookienotice/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_curweather_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_curweather_messagespo]
|
||||
file_filter = curweather/lang/<lang>/messages.po
|
||||
source_file = curweather/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_diaspora_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_diaspora_messagespo]
|
||||
file_filter = diaspora/lang/<lang>/messages.po
|
||||
source_file = diaspora/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_dwpost_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_dwpost_messagespo]
|
||||
file_filter = dwpost/lang/<lang>/messages.po
|
||||
source_file = dwpost/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_forumdirectory_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_forumdirectory_messagespo]
|
||||
file_filter = forumdirectory/lang/<lang>/messages.po
|
||||
source_file = forumdirectory/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_fromapp_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_fromapp_messagespo]
|
||||
file_filter = fromapp/lang/<lang>/messages.po
|
||||
source_file = fromapp/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_fromgplus_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_fromgplus_messagespo]
|
||||
file_filter = fromgplus/lang/<lang>/messages.po
|
||||
source_file = fromgplus/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_geonames_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_geonames_messagespo]
|
||||
file_filter = geonames/lang/<lang>/messages.po
|
||||
source_file = geonames/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_gnot_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_gnot_messagespo]
|
||||
file_filter = gnot/lang/<lang>/messages.po
|
||||
source_file = gnot/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_gravatar_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_gravatar_messagespo]
|
||||
file_filter = gravatar/lang/<lang>/messages.po
|
||||
source_file = gravatar/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_group_text_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_group_text_messagespo]
|
||||
file_filter = group_text/lang/<lang>/messages.po
|
||||
source_file = group_text/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_ifttt_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_ifttt_messagespo]
|
||||
file_filter = ifttt/lang/<lang>/messages.po
|
||||
source_file = ifttt/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_ijpost_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_ijpost_messagespo]
|
||||
file_filter = ijpost/lang/<lang>/messages.po
|
||||
source_file = ijpost/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_impressum_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_impressum_messagespo]
|
||||
file_filter = impressum/lang/<lang>/messages.po
|
||||
source_file = impressum/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_infiniteimprobabilitydrive_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_infiniteimprobabilitydrive_messagespo]
|
||||
file_filter = infiniteimprobabilitydrive/lang/<lang>/messages.po
|
||||
source_file = infiniteimprobabilitydrive/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_irc_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_irc_messagespo]
|
||||
file_filter = irc/lang/<lang>/messages.po
|
||||
source_file = irc/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_jappixmini_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_jappixmini_messagespo]
|
||||
file_filter = jappixmini/lang/<lang>/messages.po
|
||||
source_file = jappixmini/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_js_upload_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_js_upload_messagespo]
|
||||
file_filter = js_upload/lang/<lang>/messages.po
|
||||
source_file = js_upload/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_krynn_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_krynn_messagespo]
|
||||
file_filter = krynn/lang/<lang>/messages.po
|
||||
source_file = krynn/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_langfilter_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_langfilter_messagespo]
|
||||
file_filter = langfilter/lang/<lang>/messages.po
|
||||
source_file = langfilter/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_libertree_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_libertree_messagespo]
|
||||
file_filter = libertree/lang/<lang>/messages.po
|
||||
source_file = libertree/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_libravatar_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_libravatar_messagespo]
|
||||
file_filter = libravatar/lang/<lang>/messages.po
|
||||
source_file = libravatar/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_ljpost_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_ljpost_messagespo]
|
||||
file_filter = ljpost/lang/<lang>/messages.po
|
||||
source_file = ljpost/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_mailstream_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_mailstream_messagespo]
|
||||
file_filter = mailstream/lang/<lang>/messages.po
|
||||
source_file = mailstream/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_mathjax_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_mathjax_messagespo]
|
||||
file_filter = mathjax/lang/<lang>/messages.po
|
||||
source_file = mathjax/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_membersince_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_membersince_messagespo]
|
||||
file_filter = membersince/lang/<lang>/messages.po
|
||||
source_file = membersince/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_morechoice_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_morechoice_messagespo]
|
||||
file_filter = morechoice/lang/<lang>/messages.po
|
||||
source_file = morechoice/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_morepokes_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_morepokes_messagespo]
|
||||
file_filter = morepokes/lang/<lang>/messages.po
|
||||
source_file = morepokes/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_newmemberwidget_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_newmemberwidget_messagespo]
|
||||
file_filter = newmemberwidget/lang/<lang>/messages.po
|
||||
source_file = newmemberwidget/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_notifyall_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_notifyall_messagespo]
|
||||
file_filter = notifyall/lang/<lang>/messages.po
|
||||
source_file = notifyall/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_notimeline_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_notimeline_messagespo]
|
||||
file_filter = notimeline/lang/<lang>/messages.po
|
||||
source_file = notimeline/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_nsfw_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_nsfw_messagespo]
|
||||
file_filter = nsfw/lang/<lang>/messages.po
|
||||
source_file = nsfw/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_numfriends_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_numfriends_messagespo]
|
||||
file_filter = numfriends/lang/<lang>/messages.po
|
||||
source_file = numfriends/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_openstreetmap_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_openstreetmap_messagespo]
|
||||
file_filter = openstreetmap/lang/<lang>/messages.po
|
||||
source_file = openstreetmap/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_pageheader_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_pageheader_messagespo]
|
||||
file_filter = pageheader/lang/<lang>/messages.po
|
||||
source_file = pageheader/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_piwik_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_piwik_messagespo]
|
||||
file_filter = piwik/lang/<lang>/messages.po
|
||||
source_file = piwik/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_planets_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_planets_messagespo]
|
||||
file_filter = planets/lang/<lang>/messages.po
|
||||
source_file = planets/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_public_server_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_public_server_messagespo]
|
||||
file_filter = public_server/lang/<lang>/messages.po
|
||||
source_file = public_server/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_pumpio_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_pumpio_messagespo]
|
||||
file_filter = pumpio/lang/<lang>/messages.po
|
||||
source_file = pumpio/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_qcomment_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_qcomment_messagespo]
|
||||
file_filter = qcomment/lang/<lang>/messages.po
|
||||
source_file = qcomment/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_randplace_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_randplace_messagespo]
|
||||
file_filter = randplace/lang/<lang>/messages.po
|
||||
source_file = randplace/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_remote_permissions_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_remote_permissions_messagespo]
|
||||
file_filter = remote_permissions/lang/<lang>/messages.po
|
||||
source_file = remote_permissions/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_rendertime_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_rendertime_messagespo]
|
||||
file_filter = rendertime/lang/<lang>/messages.po
|
||||
source_file = rendertime/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_securemail_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_securemail_messagespo]
|
||||
file_filter = securemail/lang/<lang>/messages.po
|
||||
source_file = securemail/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_showmore_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_showmore_messagespo]
|
||||
file_filter = showmore/lang/<lang>/messages.po
|
||||
source_file = showmore/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_smileybutton_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_smileybutton_messagespo]
|
||||
file_filter = smileybutton/lang/<lang>/messages.po
|
||||
source_file = smileybutton/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_startpage_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_startpage_messagespo]
|
||||
file_filter = startpage/lang/<lang>/messages.po
|
||||
source_file = startpage/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_statusnet_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_statusnet_messagespo]
|
||||
file_filter = statusnet/lang/<lang>/messages.po
|
||||
source_file = statusnet/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_superblock_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_superblock_messagespo]
|
||||
file_filter = superblock/lang/<lang>/messages.po
|
||||
source_file = superblock/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_testdrive_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_testdrive_messagespo]
|
||||
file_filter = testdrive/lang/<lang>/messages.po
|
||||
source_file = testdrive/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_tictac_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_tictac_messagespo]
|
||||
file_filter = tictac/lang/<lang>/messages.po
|
||||
source_file = tictac/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_tumblr_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_tumblr_messagespo]
|
||||
file_filter = tumblr/lang/<lang>/messages.po
|
||||
source_file = tumblr/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_twitter_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_twitter_messagespo]
|
||||
file_filter = twitter/lang/<lang>/messages.po
|
||||
source_file = twitter/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_viewsrc_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_viewsrc_messagespo]
|
||||
file_filter = viewsrc/lang/<lang>/messages.po
|
||||
source_file = viewsrc/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_webrtc_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_webrtc_messagespo]
|
||||
file_filter = webrtc/lang/<lang>/messages.po
|
||||
source_file = webrtc/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_widgets_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_widgets_messagespo]
|
||||
file_filter = widgets/lang/<lang>/messages.po
|
||||
source_file = widgets/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_windowsphonepush_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_windowsphonepush_messagespo]
|
||||
file_filter = windowsphonepush/lang/<lang>/messages.po
|
||||
source_file = windowsphonepush/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_wppost_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_wppost_messagespo]
|
||||
file_filter = wppost/lang/<lang>/messages.po
|
||||
source_file = wppost/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
[friendica.addon_xmpp_messagespo]
|
||||
[o:Friendica:p:friendica:r:addon_xmpp_messagespo]
|
||||
file_filter = xmpp/lang/<lang>/messages.po
|
||||
source_file = xmpp/lang/C/messages.po
|
||||
source_lang = en
|
||||
type = PO
|
||||
type = PO
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
* The first PHP Library to support OAuth for Tumblr's REST API. (Originally for Twitter, modified for Tumblr by Lucas)
|
||||
*/
|
||||
|
||||
use Friendica\DI;
|
||||
use Friendica\Security\OAuth1\OAuthConsumer;
|
||||
use Friendica\Security\OAuth1\OAuthRequest;
|
||||
use Friendica\Security\OAuth1\Signature\OAuthSignatureMethod_HMAC_SHA1;
|
||||
|
@ -17,301 +18,91 @@ use Friendica\Security\OAuth1\OAuthUtil;
|
|||
*/
|
||||
class TumblrOAuth
|
||||
{
|
||||
/* Set up the API root URL. */
|
||||
public $host = "https://api.tumblr.com/v2/";
|
||||
/* Set timeout default. */
|
||||
public $timeout = 30;
|
||||
/* Set connect timeout. */
|
||||
public $connecttimeout = 30;
|
||||
/* Verify SSL Cert. */
|
||||
public $ssl_verifypeer = FALSE;
|
||||
/* Response format. */
|
||||
public $format = 'json';
|
||||
/* Decode returned json data. */
|
||||
public $decode_json = TRUE;
|
||||
/* Set the useragent. */
|
||||
public $useragent = 'TumblrOAuth v0.2.0-beta2';
|
||||
|
||||
/* Contains the last HTTP status code returned. */
|
||||
public $http_code;
|
||||
/* Contains the last API call. */
|
||||
public $url;
|
||||
/**
|
||||
* Contains the last HTTP headers returned.
|
||||
* @var array
|
||||
*/
|
||||
public $http_header;
|
||||
/**
|
||||
* Contains the last HTTP request info
|
||||
* @var string
|
||||
*/
|
||||
public $http_info;
|
||||
|
||||
/** @var OAuthToken */
|
||||
private $token;
|
||||
/** @var OAuthConsumer */
|
||||
private $consumer;
|
||||
/** @var \Friendica\Security\OAuth1\Signature\OAuthSignatureMethod_HMAC_SHA1 */
|
||||
private $sha1_method;
|
||||
|
||||
/**
|
||||
* Set API URLS
|
||||
*/
|
||||
function accessTokenURL()
|
||||
{
|
||||
return 'https://www.tumblr.com/oauth/access_token';
|
||||
}
|
||||
// API URLs
|
||||
const accessTokenURL = 'https://www.tumblr.com/oauth/access_token';
|
||||
const authorizeURL = 'https://www.tumblr.com/oauth/authorize';
|
||||
const requestTokenURL = 'https://www.tumblr.com/oauth/request_token';
|
||||
|
||||
function authenticateURL()
|
||||
{
|
||||
return 'https://www.tumblr.com/oauth/authorize';
|
||||
}
|
||||
|
||||
function authorizeURL()
|
||||
{
|
||||
return 'https://www.tumblr.com/oauth/authorize';
|
||||
}
|
||||
|
||||
function requestTokenURL()
|
||||
{
|
||||
return 'https://www.tumblr.com/oauth/request_token';
|
||||
}
|
||||
|
||||
function __construct($consumer_key, $consumer_secret, $oauth_token = null, $oauth_token_secret = null)
|
||||
function __construct(string $consumer_key, string $consumer_secret)
|
||||
{
|
||||
$this->sha1_method = new OAuthSignatureMethod_HMAC_SHA1();
|
||||
$this->consumer = new OAuthConsumer($consumer_key, $consumer_secret);
|
||||
if (!empty($oauth_token) && !empty($oauth_token_secret)) {
|
||||
$this->token = new OAuthToken($oauth_token, $oauth_token_secret);
|
||||
} else {
|
||||
$this->token = null;
|
||||
}
|
||||
$this->consumer = new OAuthConsumer($consumer_key, $consumer_secret);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a request_token from Tumblr
|
||||
*
|
||||
* @param callback $oauth_callback
|
||||
* @param string $oauth_callback
|
||||
* @return array
|
||||
*/
|
||||
function getRequestToken($oauth_callback = null)
|
||||
function getRequestToken(string $oauth_callback): array
|
||||
{
|
||||
$parameters = [];
|
||||
if (!empty($oauth_callback)) {
|
||||
$parameters['oauth_callback'] = $oauth_callback;
|
||||
}
|
||||
|
||||
$request = $this->oAuthRequest($this->requestTokenURL(), 'GET', $parameters);
|
||||
$token = OAuthUtil::parse_parameters($request);
|
||||
$this->token = new OAuthToken($token['oauth_token'], $token['oauth_token_secret']);
|
||||
return $token;
|
||||
$request = $this->oAuthRequest(self::requestTokenURL, ['oauth_callback' => $oauth_callback]);
|
||||
return OAuthUtil::parse_parameters($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the authorize URL
|
||||
*
|
||||
* @param array $token
|
||||
* @param bool $sign_in_with_tumblr
|
||||
* @param string $oauth_token
|
||||
* @return string
|
||||
*/
|
||||
function getAuthorizeURL($token, $sign_in_with_tumblr = TRUE)
|
||||
function getAuthorizeURL(string $oauth_token): string
|
||||
{
|
||||
if (is_array($token)) {
|
||||
$token = $token['oauth_token'];
|
||||
}
|
||||
|
||||
if (empty($sign_in_with_tumblr)) {
|
||||
return $this->authorizeURL() . "?oauth_token={$token}";
|
||||
} else {
|
||||
return $this->authenticateURL() . "?oauth_token={$token}";
|
||||
}
|
||||
return self::authorizeURL . "?oauth_token={$oauth_token}";
|
||||
}
|
||||
|
||||
/**
|
||||
* Exchange request token and secret for an access token and
|
||||
* secret, to sign API calls.
|
||||
*
|
||||
* @param bool $oauth_verifier
|
||||
* @param string $oauth_verifier
|
||||
* @param string $request_token
|
||||
* @param string $request_token_secret
|
||||
* @return array ("oauth_token" => "the-access-token",
|
||||
* "oauth_token_secret" => "the-access-secret",
|
||||
* "user_id" => "9436992",
|
||||
* "screen_name" => "abraham")
|
||||
*/
|
||||
function getAccessToken($oauth_verifier = FALSE)
|
||||
function getAccessToken(string $oauth_verifier, string $request_token, string $request_token_secret): array
|
||||
{
|
||||
$token = new OAuthToken($request_token, $request_token_secret);
|
||||
|
||||
$parameters = [];
|
||||
if (!empty($oauth_verifier)) {
|
||||
$parameters['oauth_verifier'] = $oauth_verifier;
|
||||
}
|
||||
|
||||
$request = $this->oAuthRequest($this->accessTokenURL(), 'GET', $parameters);
|
||||
$token = OAuthUtil::parse_parameters($request);
|
||||
$this->token = new OAuthToken($token['oauth_token'], $token['oauth_token_secret']);
|
||||
|
||||
return $token;
|
||||
}
|
||||
|
||||
/**
|
||||
* One time exchange of username and password for access token and secret.
|
||||
*
|
||||
* @param string $username
|
||||
* @param string $password
|
||||
* @return array ("oauth_token" => "the-access-token",
|
||||
* "oauth_token_secret" => "the-access-secret",
|
||||
* "user_id" => "9436992",
|
||||
* "screen_name" => "abraham",
|
||||
* "x_auth_expires" => "0")
|
||||
*/
|
||||
function getXAuthToken($username, $password)
|
||||
{
|
||||
$parameters = [];
|
||||
$parameters['x_auth_username'] = $username;
|
||||
$parameters['x_auth_password'] = $password;
|
||||
$parameters['x_auth_mode'] = 'client_auth';
|
||||
$request = $this->oAuthRequest($this->accessTokenURL(), 'POST', $parameters);
|
||||
$token = OAuthUtil::parse_parameters($request);
|
||||
$this->token = new OAuthToken($token['oauth_token'], $token['oauth_token_secret']);
|
||||
|
||||
return $token;
|
||||
}
|
||||
|
||||
/**
|
||||
* GET wrapper for oAuthRequest.
|
||||
*
|
||||
* @param string $url
|
||||
* @param array $parameters
|
||||
* @return mixed|string
|
||||
*/
|
||||
function get($url, $parameters = [])
|
||||
{
|
||||
$response = $this->oAuthRequest($url, 'GET', $parameters);
|
||||
if ($this->format === 'json' && $this->decode_json) {
|
||||
return json_decode($response);
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* POST wrapper for oAuthRequest.
|
||||
*
|
||||
* @param string $url
|
||||
* @param array $parameters
|
||||
* @return mixed|string
|
||||
*/
|
||||
function post($url, $parameters = [])
|
||||
{
|
||||
$response = $this->oAuthRequest($url, 'POST', $parameters);
|
||||
if ($this->format === 'json' && $this->decode_json) {
|
||||
return json_decode($response);
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* DELETE wrapper for oAuthReqeust.
|
||||
*
|
||||
* @param string $url
|
||||
* @param array $parameters
|
||||
* @return mixed|string
|
||||
*/
|
||||
function delete($url, $parameters = [])
|
||||
{
|
||||
$response = $this->oAuthRequest($url, 'DELETE', $parameters);
|
||||
if ($this->format === 'json' && $this->decode_json) {
|
||||
return json_decode($response);
|
||||
}
|
||||
|
||||
return $response;
|
||||
$request = $this->oAuthRequest(self::accessTokenURL, $parameters, $token);
|
||||
return OAuthUtil::parse_parameters($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format and sign an OAuth / API request
|
||||
*
|
||||
* @param string $url
|
||||
* @param string $method
|
||||
* @param array $parameters
|
||||
* @return mixed|string
|
||||
* @param string $url
|
||||
* @param array $parameters
|
||||
* @param OAuthToken $token $name
|
||||
* @return string
|
||||
*/
|
||||
function oAuthRequest($url, $method, $parameters)
|
||||
private function oAuthRequest(string $url, array $parameters, OAuthToken $token = null): string
|
||||
{
|
||||
if (strrpos($url, 'https://') !== 0 && strrpos($url, 'http://') !== 0) {
|
||||
$url = "{$this->host}{$url}";
|
||||
$request = OAuthRequest::from_consumer_and_token($this->consumer, 'GET', $url, $parameters, $token);
|
||||
$request->sign_request($this->sha1_method, $this->consumer, $token);
|
||||
|
||||
$curlResult = DI::httpClient()->get($request->to_url());
|
||||
$this->http_code = $curlResult->getReturnCode();
|
||||
if ($curlResult->isSuccess()) {
|
||||
return $curlResult->getBody();
|
||||
}
|
||||
|
||||
$request = OAuthRequest::from_consumer_and_token($this->consumer, $method, $url, $parameters, $this->token);
|
||||
$request->sign_request($this->sha1_method, $this->consumer, $this->token);
|
||||
switch ($method) {
|
||||
case 'GET':
|
||||
return $this->http($request->to_url(), 'GET');
|
||||
default:
|
||||
return $this->http($request->get_normalized_http_url(), $method, $request->to_postdata());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Make an HTTP request
|
||||
*
|
||||
* @param string $url
|
||||
* @param string $method
|
||||
* @param mixed $postfields
|
||||
* @return string API results
|
||||
*/
|
||||
function http($url, $method, $postfields = null)
|
||||
{
|
||||
$this->http_info = [];
|
||||
$ci = curl_init();
|
||||
/* Curl settings */
|
||||
curl_setopt($ci, CURLOPT_USERAGENT, $this->useragent);
|
||||
curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, $this->connecttimeout);
|
||||
curl_setopt($ci, CURLOPT_TIMEOUT, $this->timeout);
|
||||
curl_setopt($ci, CURLOPT_RETURNTRANSFER, TRUE);
|
||||
curl_setopt($ci, CURLOPT_HTTPHEADER, array('Expect:'));
|
||||
curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, $this->ssl_verifypeer);
|
||||
curl_setopt($ci, CURLOPT_HEADERFUNCTION, array($this, 'getHeader'));
|
||||
curl_setopt($ci, CURLOPT_HEADER, FALSE);
|
||||
|
||||
switch ($method) {
|
||||
case 'POST':
|
||||
curl_setopt($ci, CURLOPT_POST, TRUE);
|
||||
if (!empty($postfields)) {
|
||||
curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields);
|
||||
}
|
||||
break;
|
||||
case 'DELETE':
|
||||
curl_setopt($ci, CURLOPT_CUSTOMREQUEST, 'DELETE');
|
||||
if (!empty($postfields)) {
|
||||
$url = "{$url}?{$postfields}";
|
||||
}
|
||||
}
|
||||
|
||||
curl_setopt($ci, CURLOPT_URL, $url);
|
||||
$response = curl_exec($ci);
|
||||
$this->http_code = curl_getinfo($ci, CURLINFO_HTTP_CODE);
|
||||
$this->http_info = array_merge($this->http_info, curl_getinfo($ci));
|
||||
$this->url = $url;
|
||||
curl_close($ci);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the header info to store.
|
||||
*
|
||||
* @param resource $ch
|
||||
* @param string $header
|
||||
* @return int
|
||||
*/
|
||||
function getHeader($ch, $header)
|
||||
{
|
||||
$i = strpos($header, ':');
|
||||
if (!empty($i)) {
|
||||
$key = str_replace('-', '_', strtolower(substr($header, 0, $i)));
|
||||
$value = trim(substr($header, $i + 2));
|
||||
$this->http_header[$key] = $value;
|
||||
}
|
||||
|
||||
return strlen($header);
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,15 +10,23 @@
|
|||
require_once __DIR__ . DIRECTORY_SEPARATOR . 'library' . DIRECTORY_SEPARATOR . 'tumblroauth.php';
|
||||
|
||||
use Friendica\Content\Text\BBCode;
|
||||
use Friendica\Content\Text\NPF;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Photo;
|
||||
use Friendica\Model\Post;
|
||||
use Friendica\Model\Tag;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Network;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
use GuzzleHttp\HandlerStack;
|
||||
use GuzzleHttp\Psr7\Uri as Uri;
|
||||
use GuzzleHttp\Subscriber\Oauth\Oauth1;
|
||||
|
||||
function tumblr_install()
|
||||
{
|
||||
|
@ -109,17 +117,17 @@ function tumblr_connect()
|
|||
$request_token = $tum_oauth->getRequestToken($callback_url);
|
||||
|
||||
// Store the request token and Request Token Secret as out callback.php script will need this
|
||||
$_SESSION['request_token'] = $token = $request_token['oauth_token'];
|
||||
$_SESSION['request_token_secret'] = $request_token['oauth_token_secret'];
|
||||
DI::session()->set('request_token', $request_token['oauth_token']);
|
||||
DI::session()->set('request_token_secret', $request_token['oauth_token_secret']);
|
||||
|
||||
// Check the HTTP Code. It should be a 200 (OK), if it's anything else then something didn't work.
|
||||
switch ($tum_oauth->http_code) {
|
||||
case 200:
|
||||
// Ask Tumblr to give us a special address to their login page
|
||||
$url = $tum_oauth->getAuthorizeURL($token);
|
||||
$url = $tum_oauth->getAuthorizeURL($request_token['oauth_token']);
|
||||
|
||||
// Redirect the user to the login URL given to us by Tumblr
|
||||
header('Location: ' . $url);
|
||||
System::externalRedirect($url);
|
||||
|
||||
/*
|
||||
* That's it for our side. The user is sent to a Tumblr Login page and
|
||||
|
@ -143,7 +151,7 @@ function tumblr_callback()
|
|||
session_start();
|
||||
|
||||
// Define the needed keys
|
||||
$consumer_key = DI::config()->get('tumblr', 'consumer_key');
|
||||
$consumer_key = DI::config()->get('tumblr', 'consumer_key');
|
||||
$consumer_secret = DI::config()->get('tumblr', 'consumer_secret');
|
||||
|
||||
// Once the user approves your app at Tumblr, they are sent back to this script.
|
||||
|
@ -153,14 +161,14 @@ function tumblr_callback()
|
|||
|
||||
// Create instance of TumblrOAuth.
|
||||
// It'll need our Consumer Key and Secret as well as our Request Token and Secret
|
||||
$tum_oauth = new TumblrOAuth($consumer_key, $consumer_secret, $_SESSION['request_token'], $_SESSION['request_token_secret']);
|
||||
$tum_oauth = new TumblrOAuth($consumer_key, $consumer_secret);
|
||||
|
||||
// Ok, let's get an Access Token. We'll need to pass along our oauth_verifier which was given to us in the URL.
|
||||
$access_token = $tum_oauth->getAccessToken($_REQUEST['oauth_verifier']);
|
||||
$access_token = $tum_oauth->getAccessToken($_REQUEST['oauth_verifier'], DI::session()->get('request_token'), DI::session()->get('request_token_secret'));
|
||||
|
||||
// We're done with the Request Token and Secret so let's remove those.
|
||||
unset($_SESSION['request_token']);
|
||||
unset($_SESSION['request_token_secret']);
|
||||
DI::session()->remove('request_token');
|
||||
DI::session()->remove('request_token_secret');
|
||||
|
||||
// Make sure nothing went wrong.
|
||||
if (200 == $tum_oauth->http_code) {
|
||||
|
@ -208,20 +216,32 @@ function tumblr_settings(array &$data)
|
|||
|
||||
$oauth_token = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'tumblr', 'oauth_token');
|
||||
$oauth_token_secret = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'tumblr', 'oauth_token_secret');
|
||||
$consumer_key = DI::config()->get('tumblr', 'consumer_key');
|
||||
$consumer_secret = DI::config()->get('tumblr', 'consumer_secret');
|
||||
|
||||
if ($oauth_token && $oauth_token_secret) {
|
||||
$page = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'tumblr', 'page');
|
||||
$consumer_key = DI::config()->get('tumblr', 'consumer_key');
|
||||
$consumer_secret = DI::config()->get('tumblr', 'consumer_secret');
|
||||
if ($consumer_key && $consumer_secret && $oauth_token && $oauth_token_secret) {
|
||||
$page = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'tumblr', 'page');
|
||||
|
||||
$tum_oauth = new TumblrOAuth($consumer_key, $consumer_secret, $oauth_token, $oauth_token_secret);
|
||||
$userinfo = $tum_oauth->get('user/info');
|
||||
$blogs = [];
|
||||
|
||||
$blogs = array_map(function ($blog) {
|
||||
return substr(str_replace(['http://', 'https://'], ['', ''], $blog->url), 0, -1);
|
||||
}, $userinfo->response->user->blogs);
|
||||
$connection = tumblr_client($consumer_key, $consumer_secret, $oauth_token, $oauth_token_secret);
|
||||
if ($connection) {
|
||||
$userinfo = tumblr_get($connection, 'user/info');
|
||||
if (!empty($userinfo['success'])) {
|
||||
foreach ($userinfo['data']->response->user->blogs as $blog) {
|
||||
$uri = new Uri($blog->url);
|
||||
$url = trim($uri->getHost() . $uri->getPath(), '/');
|
||||
$blogs[$url] = $url;
|
||||
}
|
||||
}
|
||||
|
||||
$page_select = ['tumblr-page', DI::l10n()->t('Post to page:'), $page, '', $blogs];
|
||||
if (empty($page) && !empty($blogs)) {
|
||||
$page = reset($blogs);
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'tumblr', 'page', $page);
|
||||
}
|
||||
}
|
||||
|
||||
$page_select = ['tumblr_page', DI::l10n()->t('Post to page:'), $page, '', $blogs];
|
||||
}
|
||||
|
||||
$t = Renderer::getMarkupTemplate('connector_settings.tpl', 'addon/tumblr/');
|
||||
|
@ -322,108 +342,194 @@ function tumblr_send(array &$b)
|
|||
return;
|
||||
}
|
||||
|
||||
if (tumblr_send_npf($b)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$connection = tumblr_connection($b['uid']);
|
||||
if (empty($connection)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$b['body'] = BBCode::removeAttachment($b['body']);
|
||||
|
||||
$oauth_token = DI::pConfig()->get($b['uid'], 'tumblr', 'oauth_token');
|
||||
$oauth_token_secret = DI::pConfig()->get($b['uid'], 'tumblr', 'oauth_token_secret');
|
||||
$page = DI::pConfig()->get($b['uid'], 'tumblr', 'page');
|
||||
$tmbl_blog = 'blog/' . $page . '/post';
|
||||
$title = trim($b['title']);
|
||||
|
||||
if ($oauth_token && $oauth_token_secret && $tmbl_blog) {
|
||||
$tags = Tag::getByURIId($b['uri-id']);
|
||||
$media = Post\Media::getByURIId($b['uri-id'], [Post\Media::HTML, Post\Media::AUDIO, Post\Media::VIDEO, Post\Media::IMAGE]);
|
||||
|
||||
$tag_arr = [];
|
||||
$photo = array_search(Post\Media::IMAGE, array_column($media, 'type'));
|
||||
$link = array_search(Post\Media::HTML, array_column($media, 'type'));
|
||||
$audio = array_search(Post\Media::AUDIO, array_column($media, 'type'));
|
||||
$video = array_search(Post\Media::VIDEO, array_column($media, 'type'));
|
||||
|
||||
foreach ($tags as $tag) {
|
||||
$tag_arr[] = $tag['name'];
|
||||
}
|
||||
$params = [
|
||||
'state' => 'published',
|
||||
'tags' => implode(',', array_column(Tag::getByURIId($b['uri-id']), 'name')),
|
||||
'tweet' => 'off',
|
||||
'format' => 'html',
|
||||
];
|
||||
|
||||
if (count($tag_arr)) {
|
||||
$tags = implode(',', $tag_arr);
|
||||
}
|
||||
$body = BBCode::removeShareInformation($b['body']);
|
||||
$body = Post\Media::removeFromEndOfBody($body);
|
||||
|
||||
$title = trim($b['title']);
|
||||
|
||||
$media = Post\Media::getByURIId($b['uri-id'], [Post\Media::HTML, Post\Media::AUDIO, Post\Media::VIDEO, Post\Media::IMAGE]);
|
||||
|
||||
$photo = array_search(Post\Media::IMAGE, array_column($media, 'type'));
|
||||
$link = array_search(Post\Media::HTML, array_column($media, 'type'));
|
||||
$audio = array_search(Post\Media::AUDIO, array_column($media, 'type'));
|
||||
$video = array_search(Post\Media::VIDEO, array_column($media, 'type'));
|
||||
|
||||
$params = [
|
||||
'state' => 'published',
|
||||
'tags' => $tags,
|
||||
'tweet' => 'off',
|
||||
'format' => 'html',
|
||||
];
|
||||
|
||||
$body = BBCode::removeShareInformation($b['body']);
|
||||
$body = Post\Media::removeFromEndOfBody($body);
|
||||
|
||||
if ($photo !== false) {
|
||||
$params['type'] = 'photo';
|
||||
$params['caption'] = BBCode::convertForUriId($b['uri-id'], $body, BBCode::CONNECTORS);
|
||||
$params['data'] = [];
|
||||
foreach ($media as $photo) {
|
||||
if ($photo['type'] == Post\Media::IMAGE) {
|
||||
if (Network::isLocalLink($photo['url']) && ($data = Photo::getResourceData($photo['url']))) {
|
||||
$photo = Photo::selectFirst([], ["`resource-id` = ? AND `scale` > ?", $data['guid'], 0]);
|
||||
if (!empty($photo)) {
|
||||
$params['data'][] = Photo::getImageDataForPhoto($photo);
|
||||
}
|
||||
if ($photo !== false) {
|
||||
$params['type'] = 'photo';
|
||||
$params['caption'] = BBCode::convertForUriId($b['uri-id'], $body, BBCode::CONNECTORS);
|
||||
$params['data'] = [];
|
||||
foreach ($media as $photo) {
|
||||
if ($photo['type'] == Post\Media::IMAGE) {
|
||||
if (Network::isLocalLink($photo['url']) && ($data = Photo::getResourceData($photo['url']))) {
|
||||
$photo = Photo::selectFirst([], ["`resource-id` = ? AND `scale` > ?", $data['guid'], 0]);
|
||||
if (!empty($photo)) {
|
||||
$params['data'][] = Photo::getImageDataForPhoto($photo);
|
||||
}
|
||||
}
|
||||
}
|
||||
} elseif ($link !== false) {
|
||||
$params['type'] = 'link';
|
||||
$params['title'] = $media[$link]['name'];
|
||||
$params['url'] = $media[$link]['url'];
|
||||
$params['description'] = BBCode::convertForUriId($b['uri-id'], $body, BBCode::CONNECTORS);
|
||||
|
||||
if (!empty($media[$link]['preview'])) {
|
||||
$params['thumbnail'] = $media[$link]['preview'];
|
||||
}
|
||||
if (!empty($media[$link]['description'])) {
|
||||
$params['excerpt'] = $media[$link]['description'];
|
||||
}
|
||||
if (!empty($media[$link]['author-name'])) {
|
||||
$params['author'] = $media[$link]['author-name'];
|
||||
}
|
||||
} elseif ($audio !== false) {
|
||||
$params['type'] = 'audio';
|
||||
$params['external_url'] = $media[$audio]['url'];
|
||||
$params['caption'] = BBCode::convertForUriId($b['uri-id'], $body, BBCode::CONNECTORS);
|
||||
} elseif ($video !== false) {
|
||||
$params['type'] = 'video';
|
||||
$params['embed'] = $media[$video]['url'];
|
||||
$params['caption'] = BBCode::convertForUriId($b['uri-id'], $body, BBCode::CONNECTORS);
|
||||
} else {
|
||||
$params['type'] = 'text';
|
||||
$params['title'] = $title;
|
||||
$params['body'] = BBCode::convertForUriId($b['uri-id'], $b['body'], BBCode::CONNECTORS);
|
||||
}
|
||||
} elseif ($link !== false) {
|
||||
$params['type'] = 'link';
|
||||
$params['title'] = $media[$link]['name'];
|
||||
$params['url'] = $media[$link]['url'];
|
||||
$params['description'] = BBCode::convertForUriId($b['uri-id'], $body, BBCode::CONNECTORS);
|
||||
|
||||
if (isset($params['caption']) && (trim($title) != '')) {
|
||||
$params['caption'] = '<h1>' . $title . '</h1>' .
|
||||
'<p>' . $params['caption'] . '</p>';
|
||||
if (!empty($media[$link]['preview'])) {
|
||||
$params['thumbnail'] = $media[$link]['preview'];
|
||||
}
|
||||
|
||||
$consumer_key = DI::config()->get('tumblr', 'consumer_key');
|
||||
$consumer_secret = DI::config()->get('tumblr', 'consumer_secret');
|
||||
|
||||
$tum_oauth = new TumblrOAuth($consumer_key, $consumer_secret, $oauth_token, $oauth_token_secret);
|
||||
|
||||
// Make an API call with the TumblrOAuth instance.
|
||||
$x = $tum_oauth->post($tmbl_blog, $params);
|
||||
$ret_code = $tum_oauth->http_code;
|
||||
|
||||
if ($ret_code == 201) {
|
||||
Logger::info('success', ['blog' => $tmbl_blog, 'params' => $params]);
|
||||
} elseif ($ret_code == 403) {
|
||||
Logger::notice('authentication failure', ['blog' => $tmbl_blog, 'params' => $params]);
|
||||
} else {
|
||||
Logger::notice('general error', ['blog' => $tmbl_blog, 'params' => $params, 'error' => $x]);
|
||||
if (!empty($media[$link]['description'])) {
|
||||
$params['excerpt'] = $media[$link]['description'];
|
||||
}
|
||||
if (!empty($media[$link]['author-name'])) {
|
||||
$params['author'] = $media[$link]['author-name'];
|
||||
}
|
||||
} elseif ($audio !== false) {
|
||||
$params['type'] = 'audio';
|
||||
$params['external_url'] = $media[$audio]['url'];
|
||||
$params['caption'] = BBCode::convertForUriId($b['uri-id'], $body, BBCode::CONNECTORS);
|
||||
} elseif ($video !== false) {
|
||||
$params['type'] = 'video';
|
||||
$params['embed'] = $media[$video]['url'];
|
||||
$params['caption'] = BBCode::convertForUriId($b['uri-id'], $body, BBCode::CONNECTORS);
|
||||
} else {
|
||||
$params['type'] = 'text';
|
||||
$params['title'] = $title;
|
||||
$params['body'] = BBCode::convertForUriId($b['uri-id'], $b['body'], BBCode::CONNECTORS);
|
||||
}
|
||||
|
||||
if (isset($params['caption']) && (trim($title) != '')) {
|
||||
$params['caption'] = '<h1>' . $title . '</h1>' .
|
||||
'<p>' . $params['caption'] . '</p>';
|
||||
}
|
||||
|
||||
$page = DI::pConfig()->get($b['uid'], 'tumblr', 'page');
|
||||
|
||||
$result = tumblr_post($connection, 'blog/' . $page . '/post', $params);
|
||||
|
||||
if ($result['success']) {
|
||||
Logger::info('success', ['blog' => $page, 'params' => $params]);
|
||||
return true;
|
||||
} else {
|
||||
Logger::notice('error', ['blog' => $page, 'params' => $params, 'result' => $result['data']]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function tumblr_send_npf(array $post): bool
|
||||
{
|
||||
$page = DI::pConfig()->get($post['uid'], 'tumblr', 'page');
|
||||
|
||||
$connection = tumblr_connection($post['uid']);
|
||||
if (empty($connection)) {
|
||||
Logger::notice('Missing data, post will not be send to Tumblr.', ['uid' => $post['uid'], 'page' => $page, 'id' => $post['id']]);
|
||||
// "true" is returned, since the legacy function will fail as well.
|
||||
return true;
|
||||
}
|
||||
|
||||
$post['body'] = Post\Media::addAttachmentsToBody($post['uri-id'], $post['body']);
|
||||
if (!empty($post['title'])) {
|
||||
$post['body'] = '[h1]' . $post['title'] . "[/h1]\n" . $post['body'];
|
||||
}
|
||||
|
||||
$params = [
|
||||
'content' => NPF::fromBBCode($post['body'], $post['uri-id']),
|
||||
'state' => 'published',
|
||||
'date' => DateTimeFormat::utc($post['created'], DateTimeFormat::ATOM),
|
||||
'tags' => implode(',', array_column(Tag::getByURIId($post['uri-id']), 'name')),
|
||||
'is_private' => false,
|
||||
'interactability_reblog' => 'everyone'
|
||||
];
|
||||
|
||||
$result = tumblr_post($connection, 'blog/' . $page . '/posts', $params);
|
||||
|
||||
if ($result['success']) {
|
||||
Logger::info('success', ['blog' => $page, 'params' => $params]);
|
||||
return true;
|
||||
} else {
|
||||
Logger::notice('error', ['blog' => $page, 'params' => $params, 'result' => $result['data']]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function tumblr_connection(int $uid): GuzzleHttp\Client|null
|
||||
{
|
||||
$oauth_token = DI::pConfig()->get($uid, 'tumblr', 'oauth_token');
|
||||
$oauth_token_secret = DI::pConfig()->get($uid, 'tumblr', 'oauth_token_secret');
|
||||
|
||||
$page = DI::pConfig()->get($uid, 'tumblr', 'page');
|
||||
|
||||
$consumer_key = DI::config()->get('tumblr', 'consumer_key');
|
||||
$consumer_secret = DI::config()->get('tumblr', 'consumer_secret');
|
||||
|
||||
if (!$consumer_key || !$consumer_secret || !$oauth_token || !$oauth_token_secret || !$page) {
|
||||
Logger::notice('Missing data, connection is not established', ['uid' => $uid, 'page' => $page]);
|
||||
return null;
|
||||
}
|
||||
return tumblr_client($consumer_key, $consumer_secret, $oauth_token, $oauth_token_secret);
|
||||
}
|
||||
|
||||
function tumblr_client(string $consumer_key, string $consumer_secret, string $oauth_token, string $oauth_token_secret): GuzzleHttp\Client
|
||||
{
|
||||
$stack = HandlerStack::create();
|
||||
|
||||
$middleware = new Oauth1([
|
||||
'consumer_key' => $consumer_key,
|
||||
'consumer_secret' => $consumer_secret,
|
||||
'token' => $oauth_token,
|
||||
'token_secret' => $oauth_token_secret
|
||||
]);
|
||||
$stack->push($middleware);
|
||||
|
||||
return new Client([
|
||||
'base_uri' => 'https://api.tumblr.com/v2/',
|
||||
'handler' => $stack
|
||||
]);
|
||||
}
|
||||
|
||||
function tumblr_get($connection, string $url)
|
||||
{
|
||||
try {
|
||||
$res = $connection->get($url, ['auth' => 'oauth']);
|
||||
|
||||
$success = true;
|
||||
$data = json_decode($res->getBody()->getContents());
|
||||
} catch (RequestException $exception) {
|
||||
$success = false;
|
||||
Logger::notice('Request failed', ['code' => $exception->getCode(), 'message' => $exception->getMessage()]);
|
||||
$data = json_decode($exception->getResponse()->getBody()->getContents());
|
||||
}
|
||||
return ['success' => $success, 'data' => $data];
|
||||
}
|
||||
|
||||
function tumblr_post($connection, string $url, array $parameter)
|
||||
{
|
||||
try {
|
||||
$res = $connection->post($url, ['auth' => 'oauth', 'json' => $parameter]);
|
||||
|
||||
$success = true;
|
||||
$data = json_decode($res->getBody()->getContents());
|
||||
} catch (RequestException $exception) {
|
||||
$success = false;
|
||||
Logger::notice('Post failed', ['code' => $exception->getCode(), 'message' => $exception->getMessage()]);
|
||||
$data = json_decode($exception->getResponse()->getBody()->getContents());
|
||||
}
|
||||
return ['success' => $success, 'data' => $data];
|
||||
}
|
Loading…
Reference in a new issue