Querying product pricing information

Discussion in 'Shapeways API' started by leessmith, Aug 19, 2015.

  1. leessmith
    leessmith Well-Known Member
    Starting a new thread for this idea.

    Is there a way to query a models pricing information based on a supplied material OR just for all the materials available for any of my models uploaded or a specific model ID, pull down file with current pricing information that can be used to populate a product page on a website?

    Not sure how this would be implemented but I would be happy to update pricing manually daily (due to not having much turn over at the moment), in order to be able to display accurate pricing? Ideally though I would like to suck this information into a database and then link that to fields for products on my site to show any pricing changes dynamically.

    Any thoughts, suggestions, examples or whatever for this would be awesome.

    Thanks all

    S.

     
  2. panguver
    panguver Well-Known Member
    Maybe, I could download CSV-table which have prices for ALL materials at present time. Older such files had prices for "for sale" materials only.

    As example, I can:

    1. Create hidden listings for my models with unique codenames.
    2. Add it to CSV-table (you need set category for each model on SW)
    3. Download CSV-file and make "text database" and SQL-queries based on this file.
    4. You can add markup by your own tools to all models and save it to CSV-file.
    5. Upload modified file for applying changes on SW.
    6. Then you are will ready make orders.

    Best wishes.

    PS. I do similar several month already, but have troubles with uploading of giant (150k+ rows) scv-table to SW, so you will need make separate parts per model and upload it by automatic means.
     
    Last edited: Aug 20, 2015
  3. stonysmith
    stonysmith Well-Known Member Moderator
    To start, have you read thru the info on https://www.shapeways.com/api
    Then, have you tried the examples on https://github.com/Shapeways/shapeways-api

    Even though those examples may not be what you wish to do, you need to learn the background of how to make a connection, etc. Making the primitive calls to the API (with Oauth) is something you'll have to learn no matter what.
     
    Last edited: Aug 20, 2015
  4. leessmith
    leessmith Well-Known Member
    Hey,

    Where do you find the CSV up and download area? It will take me AGES to get my old mind around the API stuff (if at all), so doing it manually will be a start.

    Thanks for the reply.

    S.
     
  5. stonysmith
    stonysmith Well-Known Member Moderator
    Go to the SELL page,
    then select Settings from the menu.
    then select Pricing CSV Wizard
     
  6. leessmith
    leessmith Well-Known Member
    ok while I am looking at that I have been smashing through the API stuff... but have one error.

    I have gotten the link to return the verifer code and that works.. BUT.. on the same page I get this error.



    Call to undefined function readline() for Authorize-oauth1-pecl.php on line 37

    Which is this;

    $pin = readline("Pin: ");

    So basically I have the autheticate yourself link, which I can go to but ALSO that error.

    Is there something missing in the auth php file I should have entered first?
     
  7. leessmith
    leessmith Well-Known Member
    Looking at the readline module;

    "Note: This extension is not available on Windows platforms."

    Obviously people have a work around for this, if anyone sees this, can you share it for PHP.
     
  8. stonysmith
    stonysmith Well-Known Member Moderator
    Yeah, that part of the sample isn't really written to be used on a website. Readline() implies that you're going to read from the console, which isn't available when running PHP thru a web page.

    What I did there was split the code into two different files so that instead of using readline, you can hardcode the value into the second part.
    $pin = "012783"; #replace this with the code you received.

    One major tip.. once you get past this part, and have the ResourceOwnerKey and ResourceOwnerSecret values, you don't need to repeat this part (ever).. the ROK and ROS values don't expire. You would only have to repeat this pin business if you were doing a second account, or if you choose to add a bit of security by regenerating the ROK and ROS every couple of months. I shouldn't admit this in public, but I haven't regenerated my ROK or ROS in over two years now.
     
  9. leessmith
    leessmith Well-Known Member
    ok that makes sense. Would you just make a second file that contains everything from the readline down to the bottom.. but use the $pin = ###### as a variable at the top of the new file?
     
  10. leessmith
    leessmith Well-Known Member
    ok so I found a thread where someone put this as an option;
    //$pin = readline("Pin: ");
    $handle = fopen ("php://stdin","r");
    $pin = rtrim(fgets($handle));

    I tried that but ended up with a heap of unauthorised errors!

    'headers_sent' => string 'GET /oauth1/access_token/v1 HTTP/1.1
    User-Agent: PECL-OAuth/1.2.3
    Host: api.shapeways.com
    Accept: */*
    Authorization: OAuth oauth_consumer_key="I removed what was in here",oauth_signature_method="HMAC-SHA1",oauth_nonce="I removed what was in here",oauth_timestamp="1440132916",oauth_version="1.0",oauth_token= "I removed what was in here",oauth_signature="K2Yw6frcQBHvejsgbP9Xb0nCj3Q%3D"' (length=418)
    'headers_recv' => string 'HTTP/1.1 401 Unauthorized


    I feel like I am close, but just something minor impacting me here.
     
  11. leessmith
    leessmith Well-Known Member
    ok I did the the long way. I took the various tokens that were appearing at the points of error and made a $pin php file and have no got my tokens that I need.

    Now I cycle all the way back to one of my questions, I want to be able to populate a product page with information about my models that I have already uploaded and then send those details off to a cart when someone clicks BUY NOW.

    I don't suppose there is a leg up in the documentation anywhere for that?
     
  12. stonysmith
    stonysmith Well-Known Member Moderator
    I haven't worked with the cart section of the API.. someone else will have to help you there.

    1) cycle thru /model/v1?page= to get your entire list of models
    2) take each of the above models and use /models/xxxxxxx/info/v1 to retrieve the detail data for each model
    3) step thru the data from #2 to find IsPrintable=1 and IsActive=1 and IsPublic=1
    4) you most likely will be required to maintain a list of ModelId versus SPIN
    5) build the output page using the data from #3
    6) BuyNow..
     
    Last edited: Aug 21, 2015
  13. leessmith
    leessmith Well-Known Member
    ok cheers, I will see what I can come up with from that and then see how I can put a page together.