When trying to create a hook:
return $this->github->api('/repos/:owner/:repo/hooks', Api\Request::POST, [], [
'name' => 'web',
'active' => '1',
'events' => [
'push',
'pull_request'
],
'config' => [
'url' => 'http://example.net/some/url',
'content-type' => 'json'
]
]);
Github responds with "Problems parsing JSON". The problem appears to be here. It properly encodes values as JSON, but leaves the whole array as array. So when it is pased to CURL, it encodes it again, and messes up (doble escapes) the values.
EDIT: Just to clarify, when that line is replaced by simple $this->post = Json::encode($post);, it works, for this example. Not sure why the whole logic about UrlScript or CURLFile is there though. Probably for a reason, so it's probably not a good solution.
EDIT2: Now that I look at it, when you pass the encoded JSON string as a post parameter, it works fine. Which is probably how you're supposed to use it. Oh well, it was late last night when I wrote this :) Anyway, the issue is still relevant, because the behaviour I described is certainly not what I expected. But maybe just a clarifying docs would do the trick?...
When trying to create a hook:
Github responds with "Problems parsing JSON". The problem appears to be here. It properly encodes values as JSON, but leaves the whole array as array. So when it is pased to CURL, it encodes it again, and messes up (doble escapes) the values.
EDIT: Just to clarify, when that line is replaced by simple
$this->post = Json::encode($post);, it works, for this example. Not sure why the whole logic about UrlScript or CURLFile is there though. Probably for a reason, so it's probably not a good solution.EDIT2: Now that I look at it, when you pass the encoded JSON string as a post parameter, it works fine. Which is probably how you're supposed to use it. Oh well, it was late last night when I wrote this :) Anyway, the issue is still relevant, because the behaviour I described is certainly not what I expected. But maybe just a clarifying docs would do the trick?...