API helper class for CS-Cart 4 - FREE

Hey everyone,



I made a simply helper class for CS-Cart 4 API. With this class, everyone can easily access to the API, without getting issues with the cURL extension, headers, authentication, etc.



Just call the CSCartAPI class with 3 parameters, and after it you can access the api() method. Using is easy, and free!



Everyone can download it from my GitHub repo.



I made some tests, so it is working, but not the best at the moment. I accept suggestions, improvements and bug reports :)



Regards,



Istvan Drahos

I made a special page, for “easy download”. And optionally, if anyone want to donate my project, there is an option :)

[url=“API caller class for CS-Cart 4”]http://gum.co/ihtx[/url]

Hello.



Good work. Very useful tool.



Thanks.



Robert Diak

Hey,



Thanks. It is not documented yet, but I am on it :)


[quote name=‘soft-solid’ timestamp=‘1369127562’ post=‘162143’]

Hello.



Good work. Very useful tool.



Thanks.



Robert Diak

[/quote]

Hello



How a should add product by this tool ?

Method get, update working ok.

I have a problem z method create.



Thanks

Robert Diak

I suggest you, to use the “api()” function:

$cscart->api('POST', '/products', $data);

And make sure, you post all the mandatory fields: http://docs.cs-cart.com/api-products



If you have problem anyway, I will check the issue in the afternoon.


[quote name='soft-solid' timestamp='1369129946' post='162146']

Hello



How a should add product by this tool ?

Method get, update working ok.

I have a problem z method create.



Thanks

Robert Diak

[/quote]

Hello.



Working.



Thanks.

Hello

[quote name='drahos.istvan' timestamp='1369130213' post='162147']

I suggest you, to use the “api()” function:

$cscart->api('POST', '/products', $data);

And make sure, you post all the mandatory fields: [url=“http://docs.cs-cart.com/api-products”]http://docs.cs-cart.com/api-products[/url]



If you have problem anyway, I will check the issue in the afternoon.

[/quote]



Hello

Have you tried to add pictures to the product through the API?

Have you been able to do this successfully?



Regards

Robert Diak

Someone add product trough api with main_pair? docs can be found here , i try but no success,



My case, i upload files to ROOT/import and try to create main_pair array like this:
'main_pair' => array(
//'detailed_id'=>0, Set automatically
//'image_id'=>0, //ID of the thumbnail 0 integer
//'pair_id'=>0, //ID of the image pair Set automatically integer
//'position'=>0, //Position of the image pair among others 0 integer
//'icon'=>0, //Thumbnail data — array (similar to detailed, see below)
//'detailed'=>0, //Full image data — array (content explained below)
'absolute_path'=> dirname(__FILE__).'\import\\'.$image_name, //Absolute filesystem path to the image — Valid filesystem path
'alt'=>'', //Alternative text (show if the image fails to load) ‘’ string
'http_image_path'=>'http://www.example.com/images/'.$image_name, //HTTP path to the image — Valid HTTP URL pointing to the image
'image_path'=>'http://www.example.com/images/'.$image_name, //Actual image path (HTTP or HTTPS; may be the same as http_image_path) — Valid URL pointing to the image
'image_x'=>700, //Image width in pixels — integer
'image_y'=>621, //Image height — integer
),








Valentin

[quote name='Vali' timestamp='1371118537' post='163525']

Someone add product trough api with main_pair? docs can be found here , i try but no success,



My case, i upload files to ROOT/import and try to create main_pair array like this:
'main_pair' => array(
//'detailed_id'=>0, Set automatically
//'image_id'=>0, //ID of the thumbnail 0 integer
//'pair_id'=>0, //ID of the image pair Set automatically integer
//'position'=>0, //Position of the image pair among others 0 integer
//'icon'=>0, //Thumbnail data — array (similar to detailed, see below)
//'detailed'=>0, //Full image data — array (content explained below)
'absolute_path'=> dirname(__FILE__).'\import\\'.$image_name, //Absolute filesystem path to the image — Valid filesystem path
'alt'=>'', //Alternative text (show if the image fails to load) ‘’ string
'http_image_path'=>'http://www.example.com/images/'.$image_name, //HTTP path to the image — Valid HTTP URL pointing to the image
'image_path'=>'http://www.example.com/images/'.$image_name, //Actual image path (HTTP or HTTPS; may be the same as http_image_path) — Valid URL pointing to the image
'image_x'=>700, //Image width in pixels — integer
'image_y'=>621, //Image height — integer
),








Valentin

[/quote]



Hi Valentin,



To update/create an image for a product you shoud add a “detailed” key.

The only require parameter is “image_path”


"main_pair": {
"detailed": {
"image_path": "http://vmalyshev.u.simtech/staging/images/detailed/0/173283_0113298267324f438bac97eaf.jpg",
}
},

I have not tested yet but I’m sure is working ;)

if not, i will come back :))





Valentin

[color=#808080][size=2]part of hungryweb.net[/size][/color]

Please detail the params here.



Because I have tried multiple times and only once did it work.



I have the image url, and I first do a get to localhost/api/products/21 whcih returns the item I want.



I have then added the main_pair key value pairs as described.



I then do a put with the new information.



Does not seem to update anything nor any logging information. Seems to fail silently.



I did see it work once, but I have tried at least 100 times again and cant seem to get it to work again.



I have tried both adding both main_pair:{'detailed':{image_path as well as a list of main_pair:[detailed:{}]



Anyway I can debug this?



Thanks.

Pardon me as I pulled the trigger to early on the last post.



So here is the deal it does fail silently if the image cant be read, which I guess is debateable however the problem was on my end I was not specifing the path correctly and the server was returning a “404”.



So I hope this clarifies the last post as it does work as intended, however if the image fails to load your still not notified via error log



Thanks.

intentionaly left blank as i can't delete

any idea on random “

Ooops!

An error occurred

.” wth is going on … nothing in logs neither apache or cs-cart



product gets half created… then dies… it's in db but not admin but you can push the id to delete api once you found it… getting REALLY pissed



found it, if you copy paste some text or scrape, make sure the dumbass that made the site didnt use MSword or someother noob software, as it can contain weird chars and hidden chars that are not json safe…



“ and ” and ’ and – , these all look ok but sure arnot… therefore passing any of these in a full_description will put NULL because CS-CART parser will DROP the description and therefull the submit will error 500 the server… now why would you mod the query and still continue ? beyond understanding… server code 200 but a backend crash by the api



if i // the full description then it goes trough… i just can't think of what else to filter in the string… any ideas ?





[http_code] => 200

[header_size] => 415

[request_size] => 629

[filetime] => -1

[ssl_verify_result] => 0

[redirect_count] => 0

[total_time] => 0.562

[namelookup_time] => 0

[connect_time] => 0.031

[pretransfer_time] => 0.031

[size_upload] => 355

[size_download] => 44

[speed_download] => 78

[speed_upload] => 631

[download_content_length] => -1

[upload_content_length] => 0

[starttransfer_time] => 0.375

[redirect_time] => 0

)





Ooops!



An error occurred



Array ( )

for anyone out there, use htmlentities($string) and it will fix but put in the API itself

hi every body,

well I used this class and success to get product information in witch format I want by created my own entity.

Now I would like to know if some one try to extends api to use it to put products in cart from outside ?

I just want to know if someone do it ? if its possible and how It could be done ?

So any help any comments is well done.

Thanks a lot

MM

Just wanted to make a quick comment. I downloaded the API but was getting not found for every query. This is with multi tenant 421. I had to end up changing this line:



$params['q'] = $objectUrl;




to this:



$params['_d'] = $objectUrl;




and it started to work.



Thanks for the API. It is a lot of help!

Hi All,



I have to develop API for cs cart. They have provided me the staging site for api. I have created the api_key and enable for API access for that user from staging admin site.



And update the parameters for API call . But it always fails to authenticate with message.

Message from CS-Cart API: Unauthorized

I have tried many times but no luck.

What may be the issue can you help me?



Thanks

Denesh

To update/create an image for a product you shoud add a “detailed” key.

The only require parameter is “image_path”

[quote]


"main_pair": {
"detailed": {
"image_path": "http://vmalyshev.u.simtech/staging/images/detailed/0/173283_0113298267324f438bac97eaf.jpg",
}
},


[/quote]



Hi sir,

I am trying to upload an image from mobile using an api where I used fn_attach_image_pairs() function

But I don't know how the parametres are passed…In my app, I have to upload multiple images by browsing from gallery.

How can I use image_path?

Is the main_pair is an individual object or should i specify inside an object?

something like…

```php {“main_pair”:{“detailed”:{“image_path”:“https://upload.wikimedia.org/wikipedia/commons/thumb/d/d1/Fiat_Palio_in_Paraty.jpg/280px-Fiat_Palio_in_Paraty.jpg”}}} ```