我在阿里云code建了一個私有g(shù)it項目,阿里云code支持webhook,我用workerman來實現(xiàn)的。但是workerman獲取的阿里云code的POST數(shù)據(jù)總是格式不對:
array(1) {
=>
array(1) {
["{"id":"5a3b34c5597e9ea857fc122f373dcbaba3852","message":"ADD: testing git webhook\n","timestamp":"2016-06-23T22:45:33 08:00","url":"https://code.aliyun.com/taoqu/service/commit/5a3b34c5597ec1a857fc122f373dcbaba3852","author":{"name":"henry","email":"chary@gmail.com"},"added":=>
string(0) ""
}
}
造成json_decode無法解析。
在httpd環(huán)境下用 php://input 讀取的實際數(shù)據(jù)為:
{"object_kind":"push","before":"530aa7d005f43f54c69a885988e806653","after":"26a1e301809b34b1c1ba942e1412ec46","ref":"refs/heads/master","checkout_sha":"26a1e87870b34b1c1ba942e1412ec46","message":null,"user_id":11066,"crp_user_identity":"1896030318257386","user_name":"chary","user_email":"chary@163.com","project_id":16569,"repository":{"name":"website","url":"git@code.aliyun.com:taoq/website.git","description":"網(wǎng)站","homepage":"https://code.aliyun.com/taoq/website","git_http_url":"https://code.aliyun.com/taoq/website.git","git_ssh_url":"git@code.aliyun.com:tao/website.git","visibility_level":0},"commits":[{"id":"26a1e87870301809f18b3942e1412ec46","message":"Merge branch 'dev'\n","timestamp":"2016-09-28T09:24:00+08:00","url":"https://code.aliyun.com/taoqu/website/commit/26a1e878703018018b34b1c1ba942e1412ec46","author":{"name":"henry","email":"chariy@163.com"},"added":[],"modified":,"removed":[]},{"id":"557eeec796fa990097262097b0da43f854","message":"修復(fù)商品類層級大于3時,搜索引擎失敗的問題\n","timestamp":"2016-09-28T09:19:45+08:00","url":"https://code.aliyun.com/taoqu/website/commit/557eeec796fa99009a1cae17262097b0da43f854","author":{"name":"henry","email":"chariy@163.com"},"added":[],"modified":,"removed":[]},{"id":"530aa7d005f43f54c6bf76988e806653","message":"Merge branch 'dev'\n","timestamp":"2016-09-27T18:03:21+08:00","url":"https://code.aliyun.com/taoq/website/commit/530aa7d005f43f54c6bf50f769a885988e806653","author":{"name":"hry","email":"chary@163.com"},"added":[],"modified":,"removed":[]}],"total_commits_count":3}
這個數(shù)據(jù)是標(biāo)準(zhǔn)的json數(shù)據(jù),是可以被json_decode成功解析的。
遺憾的是workerman讀取php://input得出的是空字符串。
請問是workerman原來就這樣設(shè)計的?還是我使用上有問題?