Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

API helper class for CS-Cart 4 - FREE Rate Topic   * * * * * 2 votes

 

Posted 14 May 2013 - 11:38 PM #1

*
POPULAR

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

 

Posted 20 May 2013 - 04:08 PM #2

I made a special page, for "easy download". And optionally, if anyone want to donate my project, there is an option :)
http://gum.co/ihtx

 
  • soft-solid
  • Junior Member
  • Members
  • Join Date: 19-Apr 10
  • 251 posts

Posted 21 May 2013 - 09:12 AM #3

Hello.

Good work. Very useful tool.

Thanks.

Robert Diak

Team of SoftSolid
cs-cart.pl


 

Posted 21 May 2013 - 09:44 AM #4

Hey,

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

Hello.

Good work. Very useful tool.

Thanks.

Robert Diak



 
  • soft-solid
  • Junior Member
  • Members
  • Join Date: 19-Apr 10
  • 251 posts

Posted 21 May 2013 - 09:52 AM #5

Hello

How a should add product by this tool ?
Method get, update working ok.
I have a problem z method create.

Thanks
Robert Diak

Team of SoftSolid
cs-cart.pl


 

Posted 21 May 2013 - 09:56 AM #6

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.

Hello

How a should add product by this tool ?
Method get, update working ok.
I have a problem z method create.

Thanks
Robert Diak



 
  • soft-solid
  • Junior Member
  • Members
  • Join Date: 19-Apr 10
  • 251 posts

Posted 21 May 2013 - 10:30 AM #7

Hello.

Working.

Thanks.

Team of SoftSolid
cs-cart.pl


 
  • soft-solid
  • Junior Member
  • Members
  • Join Date: 19-Apr 10
  • 251 posts

Posted 23 May 2013 - 10:20 AM #8

Hello

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.


Hello
Have you tried to add pictures to the product through the API?
Have you been able to do this successfully?

Regards
Robert Diak

Team of SoftSolid
cs-cart.pl


 
  • Hungryweb
  • Senior Member
  • Authorized Reseller
  • Join Date: 10-Feb 12
  • 1,177 posts

Posted 13 June 2013 - 10:15 AM #9

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

 
  • imac
  • CTO
  • CS-Cart Architects
  • Join Date: 22-Nov 05
  • 1,849 posts

Posted 16 August 2013 - 11:36 AM #10

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


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",
    }
  },

Ilya Makarov,
CS-Cart Architect Team
Suggest and vote for new features | Report a bug

 
  • Hungryweb
  • Senior Member
  • Authorized Reseller
  • Join Date: 10-Feb 12
  • 1,177 posts

Posted 16 August 2013 - 08:58 PM #11

I have not tested yet but I'm sure is working ;)
if not, i will come back :))

---
Valentin
part of hungryweb.net

 
  • gotham
  • Newbie
  • Trial users
  • Join Date: 02-Oct 13
  • 3 posts

Posted 10 October 2013 - 09:19 PM #12

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.

 
  • gotham
  • Newbie
  • Trial users
  • Join Date: 02-Oct 13
  • 3 posts

Posted 10 October 2013 - 09:43 PM #13

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.

 
  • vanderex
  • Senior Member
  • Members
  • Join Date: 27-May 10
  • 378 posts

Posted 03 January 2014 - 05:15 PM #14

intentionaly left blank as i can't delete
Get Cost Effective Content Delivery CDN
Unbeatable speed, stats, & price
MaxCDN Site Acceleration

 
  • vanderex
  • Senior Member
  • Members
  • Join Date: 27-May 10
  • 378 posts

Posted 03 January 2014 - 06:43 PM #15

any idea on random "<p><h1>Ooops!</h1><h3>An error occurred</h3>." 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 ( )
Get Cost Effective Content Delivery CDN
Unbeatable speed, stats, & price
MaxCDN Site Acceleration

 
  • vanderex
  • Senior Member
  • Members
  • Join Date: 27-May 10
  • 378 posts

Posted 05 January 2014 - 08:46 PM #16

for anyone out there, use htmlentities($string) and it will fix but put in the API itself
Get Cost Effective Content Delivery CDN
Unbeatable speed, stats, & price
MaxCDN Site Acceleration

 
  • mmovies
  • Member
  • Members
  • Join Date: 30-Jul 13
  • 21 posts

Posted 14 March 2014 - 04:04 PM #17

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

 
  • jctek
  • Newbie
  • Trial users
  • Join Date: 10-Aug 14
  • 2 posts

Posted 10 August 2014 - 04:07 PM #18

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!

 
  • Denesh
  • Newbie
  • Trial users
  • Join Date: 17-Mar 15
  • 1 posts

Posted 17 March 2015 - 02:16 AM #19

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

 
  • Sekhar
  • Newbie
  • Trial users
  • Join Date: 17-Apr 15
  • 7 posts

Posted 24 June 2015 - 05:51 AM #20

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",
	}
  },


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..
{"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"}}}