Hi there. Still working with com_api and plg_users (modified) and am getting a some errors.
So I have a curl request written in php to test out my API, the code is as follows:
So first off I am creating a record with the name "thewalkingdead1" and I also want to pass a swagger spec.
If I comment out curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
I can send everything fine but the json data comes through stripped of all the characters, which is no good.
I thought that by adding the json header it wouldn't do that but now I get a {"code":403,"message":"Empty password not allowed"}.
I am trying to get the JSON passed to my plugin without it being stripped of all the non-alpha characters.
Any Help would be awesome,
Thank you.
So I have a curl request written in php to test out my API, the code is as follows:
<?php
//Json String
$json = '{"apiVersion":"1.0.0","swaggerVersion":"1.2","basePath":"http://petstore.swagger.wordnik.com/api","resourcePath":"/store","produces":["application/json"],"apis":[{"path":"/store/order","operations":[{"method":"POST","summary":"Place an order for a pet","notes":"","type":"void","nickname":"placeOrder","authorizations":{"oauth2":[{"scope":"write:pets","description":"write to your pets"}]},"parameters":[{"name":"body","description":"order placed for purchasing the pet","required":true,"type":"Order","paramType":"body","allowMultiple":false}],"responseMessages":[{"code":400,"message":"Invalid order"}]}]},{"path":"/store/order/{orderId}","operations":[{"method":"DELETE","summary":"Delete purchase order by ID","notes":"For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors","type":"void","nickname":"deleteOrder","authorizations":{"oauth2":[{"scope":"write:pets","description":"write to your pets"}]},"parameters":[{"name":"orderId","description":"ID of the order that needs to be deleted","required":true,"type":"string","paramType":"path","allowMultiple":false}],"responseMessages":[{"code":400,"message":"Invalid ID supplied"},{"code":404,"message":"Order not found"}]},{"method":"GET","summary":"Find purchase order by ID","notes":"For valid response try integer IDs with value <= 5. Anything above 5 or nonintegers will generate API errors","type":"Order","nickname":"getOrderById","authorizations":{},"parameters":[{"name":"orderId","description":"ID of pet that needs to be fetched","required":true,"type":"string","paramType":"path","allowMultiple":false}],"responseMessages":[{"code":400,"message":"Invalid ID supplied"},{"code":404,"message":"Order not found"}]}]}],"models":{"Order":{"id":"Order","properties":{"id":{"type":"integer","format":"int64"},"petId":{"type":"integer","format":"int64"},"quantity":{"type":"integer","format":"int32"},"status":{"type":"string","description":"Order Status","enum":["placed"," approved"," delivered"]},"shipDate":{"type":"string","format":"date-time"}}}}}';
$url = 'http://localhost/joomla/index.php?option=com_api&app=users&resource=users';
$data = array(
'apiname' => 'thewalkingdead1',
'key' => 'ce411cd1fb3c28923783982398',
'jsondata' => $json,
'format' => 'json',
);
$postData = "";
foreach( $data as $key => $val ) {
$postData .=$key."=".$val."&";
}
$postData = rtrim($postData, "&");
//$postData = implode('&', $data);
// Get cURL resource
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
// Send the request & save response to $resp
$resp = curl_exec($curl);
print_r($resp);
// Close request to clear up some resources
curl_close($curl);
So first off I am creating a record with the name "thewalkingdead1" and I also want to pass a swagger spec.
If I comment out curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
I can send everything fine but the json data comes through stripped of all the characters, which is no good.
I thought that by adding the json header it wouldn't do that but now I get a {"code":403,"message":"Empty password not allowed"}.
I am trying to get the JSON passed to my plugin without it being stripped of all the non-alpha characters.
Any Help would be awesome,
Thank you.