fix php warning in php5.3

This commit is contained in:
William Cheng
2015-04-08 11:33:09 +08:00
parent 73665a2b67
commit cb2f5d3e25
7 changed files with 201 additions and 103 deletions

View File

@@ -44,6 +44,7 @@ class {{classname}} {
$resourcePath = "{{path}}";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "{{httpMethod}}";
$httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
@@ -77,16 +78,19 @@ class {{classname}} {
$body = ${{paramName}};
}{{/bodyParams}}
// for model (json/xml)
if (isset($body)) {
$httpBody = $body; // $body is the method argument, if present
}
// for HTTP post (form)
$body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
$body = http_build_query($body);
$httpBody = http_build_query($formParams);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body,
$queryParams, $httpBody,
$headerParams);
{{#returnType}}if(! $response) {