前言介紹
- 這款 WordPress 外掛「Simperium」是 2014-05-15 上架。 目前已經下架不再更新,不建議安裝使用。
- 目前尚無安裝啟用數,是個很新的外掛。如有要安裝使用,建議多測試確保功能沒問題!
- 上一次更新是 2014-05-18,距離現在已有 4004 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
- 外掛最低要求 WordPress 3.6 以上版本才可以安裝。
- 尚未有人給過這款外掛評分。
- 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。
外掛協作開發者
akeda |
外掛標籤
log | data | Event | logger | Simperium | post-processing |
內容簡介
此外掛旨在讓開發人員將資料傳送到 Simperium。下列是此外掛適用的案例:
在不阻止請求的情況下進行後處理(例如在文章發布後通知十幾個網路服務),此時您可以使用提供的動作或輔助方法調用,然後從同一台伺服器或不同的伺服器生成長壽命的處理程序,以接聽您的 Simperium 桶中的更改以進行後處理。
在受限情況下(例如無法在伺服器上訪問日誌檔案)記錄發生在請求生命週期中的事件。
如何使用
安裝和啟用此外掛後,您可以使用以下方式將資料傳送至 Simperium:
通過動作鉤子:do_action( 'simperium_send_data', $bucket, $data ) 或 do_action( 'simperium_send_buffered_data', $bucket, $data )。第一個鉤子會立即傳送$data,而後者會將資料發送到緩衝區,並在調用do_action( 'simperium_flush_buffer', $bucket )之後將所有緩衝區資料一次性發送至Simperium。如果提供了$bucket參數,它將僅清除針對$bucket目標的緩衝區資料。
通過輔助方法:WP_Simperium::send_data( $bucket, $data ) 或 WP_Simperium::send_buffered_data( $bucket, $data )。要清除緩衝區,請調用WP_Simperium::flush_buffer( $bucket )。同樣,$bucket參數是可選的。
$data的值必須是鍵值配對的陣列結構,因為 Simperium 不支援巢狀結構。
在使用動作鉤子或輔助方法之前,您需要通過simperium_config篩選器提供Simperium應用程式憑證,例如:
add_filter( 'simperium_config', function() {
return array(
'app_id' => 'YOUR_APP_ID',
'api_key' => 'YOUR_API_KEY', ) } );
除了app_id和api_key,您可以將username和/或access_token傳遞到數組配置。如果省略access_token,則此外掛將從提供的username(如果存在)或get_bloginfo('admin_email')請求access_token,並將該資訊存儲在選項中。後續呼叫將從選項中讀取access_token資訊,但可以通過在數組配置中提供access_token來繞過。建議提供自己的未註冊access_token或username。請注意,令牌的壽命為30天。如果您使用外掛自動檢索的access_token,則無需擔心,因為排程事件將在29天後刷新令牌。
發送範例
我創建了一個名為sender examples plugin的外掛,您可以使用它作為開始,但在任何自訂之前均可運行。目前,它具有以下功能:
發布文章狀態轉換為公開後,發送文章資料。
發送新評論。
以後將會有更多...
消費者範例
我正在努力提供以 PHP 撰寫的聆聽者應用程式(敬請期待!),現在您可以檢查Simperium範例及其出色的程式庫。
貢獻
此外掛的開發是在GitHub上進行的。歡迎拉請求。
如需發送方應用程式的反饋,請聯繫
原文外掛簡介
This plugin is intended for developer to send data to Simperium. Followings are use cases in which this plugin might come in handy:
You need post-processing (for instance pinging dozen web services after a post is published) without blocking request. In this case you call provided actions or helper methods, then you spawn long-live process (either from the same server or different server) that listens to changes from your Simperium bucket for post-processing.
You need to log events that happen during request lifecycle under restricted circumstances (for instance it won’t possible to access log files on the server).
How to use it
Once this plugin is installed and activated, you can send data to Simperium in following ways:
Via action hook: do_action( 'simperium_send_data', $bucket, $data ) or do_action( 'simperium_send_buffered_data', $bucket, $data ). The first hook, will send the $data immediately, while the later will send the data to buffer and will send all buffered data to Simperium at once after calling do_action( 'simperium_flush_buffer', $bucket ). If $bucket arg is provided, it only flushes buffered data that’s targetted to $bucket.
Via helper method: WP_Simperium::send_data( $bucket, $data ) or WP_Simperium::send_buffered_data( $bucket, $data ). To flush buffer, you call WP_Simperium::flush_buffer( $bucket ). Again, $bucket arg is optional.
The value of $data MUST BE in key-value array structure as nested structure is not supported by Simperium.
Before using the action hooks or helper methods, you need to supply Simperium app credentials via simperium_config filter, for example:
add_filter( 'simperium_config', function() { return array( 'app_id' => 'YOUR_APP_ID', 'api_key' => 'YOUR_API_KEY', ) } );
In addition to app_id and api_key you can pass username and/or access_token to the array config. If access_token is omitted, the plugin will request access_token from Simperium with provided username (if exists) or get_bloginfo( 'admin_email' ) and store the info in option. Subsequent calls will read access_token information from option, but can be bypassed by providing access_token in array config. It’s preferred to supply your own access_token or username that hasn’t registered yet. Please keep in mind that token has 30 days life span. If you’re using access_token that’s automatically retrieved by the plugin, you don’t need to worry as scheduled event will refresh the token per 29 days.
Sender Examples
I’ve created sender examples plugin that you can use as a starting point, though it will run without any customization. Currently it has following features:
Send post data once post status is transitioned to public.
Send new comment.
More will come later..
Consumer Examples
I’m working to provide listener apps, written in PHP (stay tuned!), for now you can check Simperium examples and their awesome libraries.
Contributing
Development of this plugin is done on GitHub. Pull requests are always welcome.
For Sender apps feedback, please check its GitHub repo.
For Consumer apps feedback, please stay tuned!
各版本下載點
- 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
- 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「Simperium」來進行安裝。
(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。
延伸相關外掛(你可能也想知道)
暫無相關外掛推薦。