├── ruby
├── api_url_base.yaml
├── access_tokens.yaml
├── consumer_keys.yaml
├── Gemfile
├── Gemfile.lock
├── model_get.rb
├── model_download.rb
├── model_update.rb
├── model_upload.rb
├── README.md
├── authorize.rb
└── order_reprint.rb
├── php-pecl
├── api_url_base.php
├── access_token.php
├── consumer_key.php
├── CartList-oauth1-pecl.php
├── MaterialList-oauth1-pecl.php
├── PrinterList-oauth1-pecl.php
├── ApiList-oauth1-pecl.php
├── PrinterGet-oauth1-pecl.php
├── ModelGet-oauth1-pecl.php
├── MaterialInfo-oauth1-pecl.php
├── ModelDownload-oauth1-pecl.php
├── ModelUpdate-oauth1-pecl.php
├── OrderGet-oauth1-pecl.php
├── CartAddModel-oauth1-pecl.php
├── README.md
├── ModelUpload-oauth1-pecl.php
├── OrderReprint-oauth1-pecl.php
├── ShapeJSCustomization-oauth1-pecl.php
├── PriceModel-oauth1-pecl.php
├── error.php
├── OrderPost-oauth1-pecl.php
└── Authorize-oauth1-pecl.php
├── pictures
└── customPic.png
├── models
├── test2_Textures_wrl.zip
└── cube-1cm3-centered_in_meter.stl
├── dot-net
├── API Example
│ ├── packages.config
│ ├── Web.config
│ ├── Login.aspx
│ ├── Callback.aspx
│ ├── Default.aspx
│ ├── Login.aspx.cs
│ ├── Login.aspx.designer.cs
│ ├── Callback.aspx.designer.cs
│ ├── Default.aspx.designer.cs
│ ├── Default.aspx.cs
│ ├── Callback.aspx.cs
│ ├── Web.Debug.config
│ ├── Web.Release.config
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── ShapewaysClient.cs
│ └── API Example.csproj
├── README.md
├── API Example.sln
└── .gitignore
├── README.md
└── php-curl
└── AuthorizeWithRequestUriQuery-oauth1-curl.php
/ruby/api_url_base.yaml:
--------------------------------------------------------------------------------
1 | api_url_base: "http://api.shapeways.com"
2 |
--------------------------------------------------------------------------------
/ruby/access_tokens.yaml:
--------------------------------------------------------------------------------
1 | access_token: "" #CHANGEME
2 | access_secret: "" #CHANGEME
3 |
--------------------------------------------------------------------------------
/ruby/consumer_keys.yaml:
--------------------------------------------------------------------------------
1 | consumer_key: "" #CHANGEME
2 | consumer_secret: "" #CHANGEME
3 |
--------------------------------------------------------------------------------
/ruby/Gemfile:
--------------------------------------------------------------------------------
1 | source "http://rubygems.org"
2 |
3 | gem 'json', "1.8.1"
4 | gem 'oauth'
5 |
--------------------------------------------------------------------------------
/php-pecl/api_url_base.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/dot-net/README.md:
--------------------------------------------------------------------------------
1 | Shapeways API Dot Net Example
2 | =============================
3 |
4 | This is a simple example code accessing the Shapeways API from .NET.
5 |
6 | This code utilizes https://github.com/danielcrenna/oauth OAuth library and
7 | http://james.newtonking.com/json json library.
8 |
--------------------------------------------------------------------------------
/ruby/model_get.rb:
--------------------------------------------------------------------------------
1 | require 'bundler/setup'
2 | Bundler.require
3 | require_relative 'authorize.rb'
4 |
5 | # model information
6 | model_id = 1234567 #CHANGEME
7 |
8 | # get request
9 | json_response = @accesstoken.get("/models/#{model_id}/info/v1")
10 | model = JSON.parse(json_response.body)
11 |
12 | puts JSON.pretty_generate(model)
13 |
--------------------------------------------------------------------------------
/ruby/model_download.rb:
--------------------------------------------------------------------------------
1 | require 'bundler/setup'
2 | Bundler.require
3 | require_relative 'authorize.rb'
4 |
5 | # model information
6 | model_id = 1234567 #CHANGEME
7 | model_version = 0 #CHANGEME
8 |
9 | # get request
10 | json_response = @accesstoken.get("/models/#{model_id}/files/#{model_version}/v1?file=1")
11 | model = JSON.parse(json_response.body)
12 |
13 | puts JSON.pretty_generate(model)
14 |
--------------------------------------------------------------------------------
/dot-net/API Example/Web.config:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/dot-net/API Example/Login.aspx:
--------------------------------------------------------------------------------
1 | <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="API_Example.Login" %>
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/dot-net/API Example/Callback.aspx:
--------------------------------------------------------------------------------
1 | <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Callback.aspx.cs" Inherits="API_Example.Callback" %>
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/ruby/model_update.rb:
--------------------------------------------------------------------------------
1 | require 'bundler/setup'
2 | Bundler.require
3 | require_relative 'authorize.rb'
4 |
5 | # model information
6 | model_id = 1234567 #CHANGEME
7 |
8 | # put request
9 | json_response = @accesstoken.put("/models/#{model_id}/info/v1",
10 | {'isPublic': 1, 'isForSale': 1}.to_json,
11 | {'Content-Type' => 'application/json'}
12 | )
13 | model = JSON.parse(json_response.body)
14 |
15 | puts JSON.pretty_generate(model)
16 |
--------------------------------------------------------------------------------
/dot-net/API Example/Default.aspx:
--------------------------------------------------------------------------------
1 | <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="API_Example.Default" %>
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Shapeways API Reference Clients
2 | ===============================
3 |
4 | This repo contains some sample applications for interacting with
5 | the http://www.shapeways.com [API](http://developers.shapeways.com).
6 |
7 | ## Supported Language Clients
8 |
9 | - [PHP](http://github.com/Shapeways/php-shapeways)
10 | - [NodeJS](http://github.com/Shapeways/node-shapeways)
11 | - [Python](http://github.com/Shapeways/python-shapeways)
12 | - [Go](http://github.com/Shapeways/go-shapeways)
13 |
14 | ## TODO
15 |
16 | - C
17 | - C++
18 | - Java
19 | - Perl
20 | - Ruby
21 |
--------------------------------------------------------------------------------
/ruby/model_upload.rb:
--------------------------------------------------------------------------------
1 | require 'bundler/setup'
2 | Bundler.require
3 | require_relative 'authorize.rb'
4 |
5 | # file information
6 | file_name = 'cube-1cm3-centered_in_meter.stl' #CHANGEME
7 | file = File.read('../models/' + file_name) #CHANGEME
8 |
9 | # post request
10 | json_response = @accesstoken.post('/models/v1',
11 | {'fileName' => file_name, 'file' => URI.escape(Base64.encode64(file), Regexp.new('[^#{URI::PATTERN::UNRESERVED}]')), 'hasRightsToModel' => 1, 'acceptTermsAndConditions' => 1}.to_json,
12 | {'Content-Type' => 'application/json'})
13 | model = JSON.parse(json_response.body)
14 |
15 | puts JSON.pretty_generate(model)
16 |
--------------------------------------------------------------------------------
/ruby/README.md:
--------------------------------------------------------------------------------
1 | Shapeways REST API sample Ruby applications
2 | ===============================================
3 |
4 | Sample applications for the Shapeways REST API in ruby
5 |
6 | ## Installation
7 | 1. install ruby
8 | 2. `gem install bundler`
9 | 3. `bundle install`
10 |
11 | ## Configuration
12 | 1. Get an oauth1 `Consumer Key` at and store the `Consumer Key` in `consumer_keys.yaml`
13 | 2. Acquire an `Access Token` and store it in `access_tokens.yaml`
14 |
15 | ## Sample scripts
16 | - model_download.rb Download a model.
17 | - model_get.rb Show model properties.
18 | - model_update.rb Update model properties.
19 | - model_upload.rb Upload a model.
20 |
--------------------------------------------------------------------------------
/ruby/authorize.rb:
--------------------------------------------------------------------------------
1 | require 'bundler/setup'
2 | Bundler.require
3 | require 'yaml'
4 |
5 | # grab oauth creds from yaml files
6 | consumer_keys = YAML.load_file('consumer_keys.yaml')
7 | access_tokens = YAML.load_file('access_tokens.yaml')
8 | api_url_base = YAML.load_file('api_url_base.yaml')
9 |
10 | consumer_key = consumer_keys['consumer_key']
11 | consumer_secret = consumer_keys['consumer_secret']
12 |
13 | access_token = access_tokens['access_token']
14 | access_secret = access_tokens['access_secret']
15 | url = api_url_base['api_url_base']
16 |
17 | # get oauth access token
18 | @consumer = OAuth::Consumer.new(consumer_key, consumer_secret, {:site=>url})
19 | @accesstoken = OAuth::AccessToken.new(@consumer, access_token, access_secret)
20 |
--------------------------------------------------------------------------------
/ruby/order_reprint.rb:
--------------------------------------------------------------------------------
1 | require 'bundler/setup'
2 | Bundler.require
3 | require_relative 'authorize.rb'
4 |
5 | # NOTE - You must have special access to use this endpoint. Please request access from the Business Development Team here - https://www.shapeways.com/contact/contact-form
6 |
7 | # order information
8 | order_id = 1234567 #CHANGEME
9 |
10 | # post request
11 | json_response = @accesstoken.post("/orders/#{order_id}/reprint/v1",
12 | {
13 | 'orderProductId' => 1234567, #CHANGEME
14 | 'reprintReasonId' => 503, #CHANGEME
15 | 'reprintComment' => 'This should be at least 10 characters', #CHANGEME
16 | 'quantity' => 1 #CHANGEME
17 | }.to_json,
18 | {'Content-Type' => 'application/json'})
19 | order = JSON.parse(json_response.body)
20 |
21 | puts JSON.pretty_generate(order)
22 |
--------------------------------------------------------------------------------
/dot-net/API Example/Login.aspx.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Web;
5 | using System.Web.UI;
6 | using System.Web.UI.WebControls;
7 |
8 | namespace API_Example
9 | {
10 | public partial class Login : System.Web.UI.Page
11 | {
12 | protected void Page_Load(object sender, EventArgs e)
13 | {
14 | ShapewaysClient client = new ShapewaysClient(
15 | "CONSUMER TOKEN",
16 | "CONSUMER SECRET",
17 | "http://localhost:49314/Callback.aspx"
18 | );
19 |
20 | var url = client.connect();
21 | Session["oauth_token"] = client.OAuthToken;
22 | Session["oauth_secret"] = client.OAuthSecret;
23 | Response.Redirect(url);
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/dot-net/API Example/Login.aspx.designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | //
5 | // Changes to this file may cause incorrect behavior and will be lost if
6 | // the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 | namespace API_Example
11 | {
12 |
13 |
14 | public partial class Login
15 | {
16 |
17 | ///
18 | /// form1 control.
19 | ///
20 | ///
21 | /// Auto-generated field.
22 | /// To modify move field declaration from designer file to code-behind file.
23 | ///
24 | protected global::System.Web.UI.HtmlControls.HtmlForm form1;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/dot-net/API Example/Callback.aspx.designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | //
5 | // Changes to this file may cause incorrect behavior and will be lost if
6 | // the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 | namespace API_Example
11 | {
12 |
13 |
14 | public partial class Callback
15 | {
16 |
17 | ///
18 | /// form1 control.
19 | ///
20 | ///
21 | /// Auto-generated field.
22 | /// To modify move field declaration from designer file to code-behind file.
23 | ///
24 | protected global::System.Web.UI.HtmlControls.HtmlForm form1;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/dot-net/API Example/Default.aspx.designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | //
5 | // Changes to this file may cause incorrect behavior and will be lost if
6 | // the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 | namespace API_Example {
11 |
12 |
13 | public partial class Default {
14 |
15 | ///
16 | /// form1 control.
17 | ///
18 | ///
19 | /// Auto-generated field.
20 | /// To modify move field declaration from designer file to code-behind file.
21 | ///
22 | protected global::System.Web.UI.HtmlControls.HtmlForm form1;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/dot-net/API Example/Default.aspx.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Web;
5 | using System.Web.UI;
6 | using System.Web.UI.WebControls;
7 |
8 | namespace API_Example
9 | {
10 | public partial class Default : System.Web.UI.Page
11 | {
12 | public object apiInfo;
13 |
14 | protected void Page_Load(object sender, EventArgs e)
15 | {
16 | if (Session["oauth_secret"] == null || Session["oauth_token"] == null)
17 | {
18 | Response.Redirect("/Login.aspx");
19 | return;
20 | }
21 | ShapewaysClient client = new ShapewaysClient(
22 | "CONSUMER TOKEN",
23 | "CONSUMER SECRET",
24 | "http://localhost:49314/Callback.aspx"
25 | );
26 | client.OAuthSecret = Session["oauth_secret"].ToString();
27 | client.OAuthToken = Session["oauth_token"].ToString();
28 | this.apiInfo = client.getApiInfo();
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/dot-net/API Example.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Express 2013 for Web
4 | VisualStudioVersion = 12.0.21005.1
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "API Example", "API Example\API Example.csproj", "{94A6E38F-1585-4485-A7B7-6BFE89E03252}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {94A6E38F-1585-4485-A7B7-6BFE89E03252}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {94A6E38F-1585-4485-A7B7-6BFE89E03252}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {94A6E38F-1585-4485-A7B7-6BFE89E03252}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {94A6E38F-1585-4485-A7B7-6BFE89E03252}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | EndGlobal
23 |
--------------------------------------------------------------------------------
/dot-net/API Example/Callback.aspx.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Web;
5 | using System.Web.UI;
6 | using System.Web.UI.WebControls;
7 |
8 | namespace API_Example
9 | {
10 | public partial class Callback : System.Web.UI.Page
11 | {
12 | protected void Page_Load(object sender, EventArgs e)
13 | {
14 | if (Session["oauth_secret"] == null)
15 | {
16 | Response.Redirect("/Login.aspx");
17 | return;
18 | }
19 | ShapewaysClient client = new ShapewaysClient(
20 | "CONSUMER TOKEN",
21 | "CONSUMER SECRET",
22 | "http://localhost:49314/Callback.aspx"
23 | );
24 | client.OAuthSecret = Session["oauth_secret"].ToString();
25 | client.verifyUrl(Request.RawUrl);
26 | Session["oauth_secret"] = client.OAuthSecret;
27 | Session["oauth_token"] = client.OAuthToken;
28 | Response.Redirect("/");
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/php-pecl/CartList-oauth1-pecl.php:
--------------------------------------------------------------------------------
1 | #!/usr/bin/php
2 | enableDebug();
12 | $oauth->setToken($access_token, $access_secret);
13 | } catch(OAuthException $E) {
14 | Error("setup exception", $E->getMessage(), null, null, $E->debugInfo, $E->getFile(), $E->getLine());
15 | }
16 |
17 | try {
18 | $oauth->fetch($api_url_base ."/orders/cart/v1", null, OAUTH_HTTP_METHOD_GET, array("Accept" => "application/json"));
19 | $response = $oauth->getLastResponse();
20 | $json = json_decode($response);
21 | if (null == $json) {
22 | PrintJsonLastError();
23 | var_dump($response);
24 | } else {
25 | print_r($json);
26 | }
27 | } catch(OAuthException $E) {
28 | Error("fetch exception", $E->getMessage(), $oauth->getLastResponse(), $oauth->getLastResponseInfo(), $E->debugInfo, $E->getFile(), $E->getLine());
29 | }
30 |
31 | ?>
32 |
33 |
--------------------------------------------------------------------------------
/php-pecl/MaterialList-oauth1-pecl.php:
--------------------------------------------------------------------------------
1 | #!/usr/bin/php
2 | enableDebug();
12 | $oauth->setToken($access_token, $access_secret);
13 | } catch(OAuthException $E) {
14 | Error("setup exception", $E->getMessage(), null, null, $E->debugInfo, $E->getFile(), $E->getLine());
15 | }
16 |
17 | try {
18 | $oauth->fetch($api_url_base ."/materials/v1", null, OAUTH_HTTP_METHOD_GET, array("Accept" => "application/json"));
19 | $response = $oauth->getLastResponse();
20 | $json = json_decode($response);
21 | if (null == $json) {
22 | PrintJsonLastError();
23 | var_dump($response);
24 | } else {
25 | print_r($json);
26 | }
27 |
28 | } catch(OAuthException $E) {
29 | Error("fetch exception", $E->getMessage(), $oauth->getLastResponse(), $oauth->getLastResponseInfo(), $E->debugInfo, $E->getFile(), $E->getLine());
30 | }
31 |
32 | ?>
33 |
34 |
--------------------------------------------------------------------------------
/php-pecl/PrinterList-oauth1-pecl.php:
--------------------------------------------------------------------------------
1 | #!/usr/bin/php
2 | enableDebug();
12 | $oauth->setToken($access_token, $access_secret);
13 | } catch(OAuthException $E) {
14 | Error("setup exception", $E->getMessage(), null, null, $E->debugInfo, $E->getFile(), $E->getLine());
15 | }
16 |
17 | try {
18 | $oauth->fetch($api_url_base ."/printers/v1", null, OAUTH_HTTP_METHOD_GET, array("Accept" => "application/json"));
19 | $response = $oauth->getLastResponse();
20 | $json = json_decode($response);
21 | if (null == $json) {
22 | PrintJsonLastError();
23 | var_dump($response);
24 | } else {
25 | print_r($json);
26 | }
27 |
28 | } catch(OAuthException $E) {
29 | Error("fetch exception", $E->getMessage(), $oauth->getLastResponse(), $oauth->getLastResponseInfo(), $E->debugInfo, $E->getFile(), $E->getLine());
30 | }
31 |
32 | ?>
33 |
34 |
--------------------------------------------------------------------------------
/php-pecl/ApiList-oauth1-pecl.php:
--------------------------------------------------------------------------------
1 | #!/usr/bin/php
2 | enableDebug();
13 | $oauth->setToken($access_token, $access_secret);
14 | } catch(OAuthException $E) {
15 | Error("setup exception", $E->getMessage(), null, null, $E->debugInfo, $E->getFile(), $E->getLine());
16 | }
17 |
18 | try {
19 | $oauth->fetch($api_url_base ."/api/v1", null, OAUTH_HTTP_METHOD_GET, array("Accept" => "application/json"));
20 | $response = $oauth->getLastResponse();
21 | $json = json_decode($response);
22 | if (null == $json) {
23 | PrintJsonLastError();
24 | var_dump($response);
25 | } else {
26 | print_r($json);
27 | }
28 |
29 | } catch(OAuthException $E) {
30 | Error("fetch exception", $E->getMessage(), $oauth->getLastResponse(), $oauth->getLastResponseInfo(), $E->debugInfo, $E->getFile(), $E->getLine());
31 | }
32 |
33 | ?>
34 |
35 |
--------------------------------------------------------------------------------
/php-pecl/PrinterGet-oauth1-pecl.php:
--------------------------------------------------------------------------------
1 | #!/usr/bin/php
2 | enableDebug();
12 | $oauth->setToken($access_token, $access_secret);
13 | } catch(OAuthException $E) {
14 | Error("setup exception", $E->getMessage(), null, null, $E->debugInfo, $E->getFile(), $E->getLine());
15 | }
16 |
17 | try {
18 | $printerId=1;
19 | $oauth->fetch($api_url_base ."/printers/$printerId/v1", null, OAUTH_HTTP_METHOD_GET, array("Accept" => "application/json"));
20 | $response = $oauth->getLastResponse();
21 | $json = json_decode($response);
22 | if (null == $json) {
23 | PrintJsonLastError();
24 | var_dump($response);
25 | } else {
26 | print_r($json);
27 | }
28 |
29 | } catch(OAuthException $E) {
30 | Error("fetch exception", $E->getMessage(), $oauth->getLastResponse(), $oauth->getLastResponseInfo(), $E->debugInfo, $E->getFile(), $E->getLine());
31 | }
32 |
33 | ?>
34 |
35 |
--------------------------------------------------------------------------------
/php-pecl/ModelGet-oauth1-pecl.php:
--------------------------------------------------------------------------------
1 | #!/usr/bin/php
2 | enableDebug();
12 | $oauth->setToken($access_token, $access_secret);
13 | } catch(OAuthException $E) {
14 | Error("setup exception", $E->getMessage(), null, null, $E->debugInfo, $E->getFile(), $E->getLine());
15 | }
16 |
17 | try {
18 | $modelId = 1234567; # CHANGEME
19 | $oauth->fetch($api_url_base ."/models/$modelId/v1", null, OAUTH_HTTP_METHOD_GET, array("Accept" => "application/json"));
20 | $response = $oauth->getLastResponse();
21 | $json = json_decode($response);
22 | if (null == $json) {
23 | PrintJsonLastError();
24 | var_dump($response);
25 | } else {
26 | print_r($json);
27 | }
28 | } catch(OAuthException $E) {
29 | Error("fetch exception", $E->getMessage(), $oauth->getLastResponse(), $oauth->getLastResponseInfo(), $E->debugInfo, $E->getFile(), $E->getLine());
30 | }
31 |
32 | ?>
33 |
34 |
--------------------------------------------------------------------------------
/php-pecl/MaterialInfo-oauth1-pecl.php:
--------------------------------------------------------------------------------
1 | #!/usr/bin/php
2 | enableDebug();
12 | $oauth->setToken($access_token, $access_secret);
13 | } catch(OAuthException $E) {
14 | Error("setup exception", $E->getMessage(), null, null, $E->debugInfo, $E->getFile(), $E->getLine());
15 | }
16 |
17 | try {
18 | $materialId = 26; # CHANGEME
19 | $oauth->fetch($api_url_base ."/materials/$materialId/v1", null, OAUTH_HTTP_METHOD_GET, array("Accept" => "application/json"));
20 | $response = $oauth->getLastResponse();
21 | $json = json_decode($response);
22 | if (null == $json) {
23 | PrintJsonLastError();
24 | var_dump($response);
25 | } else {
26 | print_r($json);
27 | }
28 | } catch(OAuthException $E) {
29 | Error("fetch exception", $E->getMessage(), $oauth->getLastResponse(), $oauth->getLastResponseInfo(), $E->debugInfo, $E->getFile(), $E->getLine());
30 | }
31 |
32 | ?>
33 |
34 |
--------------------------------------------------------------------------------
/php-pecl/ModelDownload-oauth1-pecl.php:
--------------------------------------------------------------------------------
1 | #!/usr/bin/php
2 | enableDebug();
12 | $oauth->setToken($access_token, $access_secret);
13 | } catch(OAuthException $E) {
14 | Error("setup exception", $E->getMessage(), null, null, $E->debugInfo, $E->getFile(), $E->getLine());
15 | }
16 |
17 | try {
18 | $modelId = 1234567; # CHANGEME
19 | $modelVersion = 0; # CHANGEME
20 | $oauth->fetch($api_url_base ."/models/$modelId/files/$modelVersion/v1?file=1", null, OAUTH_HTTP_METHOD_GET, array("Accept" => "application/json"));
21 | $response = $oauth->getLastResponse();
22 | $json = json_decode($response);
23 | if (null == $json) {
24 | PrintJsonLastError();
25 | var_dump($response);
26 | } else {
27 | print_r($json);
28 | }
29 | } catch(OAuthException $E) {
30 | Error("fetch exception", $E->getMessage(), $oauth->getLastResponse(), $oauth->getLastResponseInfo(), $E->debugInfo, $E->getFile(), $E->getLine());
31 | }
32 |
33 | ?>
34 |
35 |
--------------------------------------------------------------------------------
/php-pecl/ModelUpdate-oauth1-pecl.php:
--------------------------------------------------------------------------------
1 | #!/usr/bin/php
2 | enableDebug();
12 | $oauth->setToken($access_token, $access_secret);
13 | } catch(OAuthException $E) {
14 | Error("setup exception", $E->getMessage(), null, null, $E->debugInfo, $E->getFile(), $E->getLine());
15 | }
16 |
17 | $modelId = 1234567; #CHANGEME
18 | $data = array(
19 | "isPublic" => 1,
20 | "isForSale" => 1,
21 | );
22 | try {
23 | $data_string = json_encode($data);
24 | $oauth->fetch(
25 | $api_url_base . "/models/" . $modelId . "/info/v1/",
26 | $data_string,
27 | OAUTH_HTTP_METHOD_PUT,
28 | array('Content-Type' => 'application/json')
29 | );
30 | $response = $oauth->getLastResponse();
31 | $json = json_decode($response);
32 | if (null == $json) {
33 | PrintJsonLastError();
34 | var_dump($response);
35 | } else {
36 | print_r($json);
37 | }
38 | } catch (OAuthException $E) {
39 | Error("fetch exception", $E->getMessage(), $oauth->getLastResponse(), $oauth->getLastResponseInfo(), $E->debugInfo, $E->getFile(), $E->getLine());
40 | }
41 |
--------------------------------------------------------------------------------
/dot-net/API Example/Web.Debug.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
29 |
30 |
--------------------------------------------------------------------------------
/php-pecl/OrderGet-oauth1-pecl.php:
--------------------------------------------------------------------------------
1 | #!/usr/bin/php
2 | enableDebug();
14 | $oauth->setToken($access_token, $access_secret);
15 | } catch(OAuthException $E) {
16 | Error("setup exception", $E->getMessage(), null, null, $E->debugInfo, $E->getFile(), $E->getLine());
17 | }
18 |
19 | try {
20 | $orderId = 12345; // CHANGEME
21 | $data = array("orderId" => $orderId);
22 |
23 | $data_string = json_encode($data);
24 |
25 | $oauth->fetch($api_url_base ."/orders/$orderId/v1", null, OAUTH_HTTP_METHOD_GET, array("Accept" => "application/json"));
26 |
27 | $response = $oauth->getLastResponse();
28 | $json = json_decode($response);
29 | if (null == $json) {
30 | PrintJsonLastError();
31 | var_dump($response);
32 | } else {
33 | print_r($json);
34 | }
35 |
36 | } catch(OAuthException $E) {
37 | Error("fetch exception", $E->getMessage(), $oauth->getLastResponse(), $oauth->getLastResponseInfo(), $E->debugInfo, $E->getFile(), $E->getLine());
38 | }
39 |
40 | ?>
41 |
42 |
--------------------------------------------------------------------------------
/dot-net/API Example/Web.Release.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
19 |
30 |
31 |
--------------------------------------------------------------------------------
/php-pecl/CartAddModel-oauth1-pecl.php:
--------------------------------------------------------------------------------
1 | #!/usr/bin/php
2 | enableDebug();
12 | $oauth->setToken($access_token, $access_secret);
13 | } catch(OAuthException $E) {
14 | Error("setup exception", $E->getMessage(), null, null, $E->debugInfo, $E->getFile(), $E->getLine());
15 | }
16 |
17 | try {
18 | $modelId = 24470; # CHANGEME
19 | $data = array("modelId" => "$modelId",
20 | "materialId" => 62, #CHANGEME (must be a material that is enabled for sale)
21 | "quantity" => 1,
22 | "scale" => 1,
23 | );
24 | $data_string = json_encode($data);
25 | $oauth->fetch($api_url_base ."/orders/cart/v1", $data_string, OAUTH_HTTP_METHOD_POST, array("Accept" => "application/json", "Content-Type" => "application/json"));
26 | $response = $oauth->getLastResponse();
27 | $json = json_decode($response);
28 | if (null == $json) {
29 | PrintJsonLastError();
30 | var_dump($response);
31 | } else {
32 | print_r($json);
33 | }
34 | } catch(OAuthException $E) {
35 | Error("fetch exception", $E->getMessage(), $oauth->getLastResponse(), $oauth->getLastResponseInfo(), $E->debugInfo, $E->getFile(), $E->getLine());
36 | }
37 |
38 | ?>
39 |
40 |
--------------------------------------------------------------------------------
/php-pecl/README.md:
--------------------------------------------------------------------------------
1 | Shapeways REST API sample PHP/PECL applications
2 | ===============================================
3 |
4 | Sample applications for the Shapeways REST API in PHP/PECL
5 |
6 | ## Installation
7 |
8 | 1. install php
9 | 2. install php-pear
10 | 3. pecl install oauth
11 |
12 | ## Configuration
13 |
14 | 1. Get an oauth1 `Consumer Key` at and store the `Consumer Key` in `consumer_key.php`
15 | 2. Run `Authorize-oauth1-pecl.php` to :
16 | - get temporary credentials (aka a `Request Token`)
17 | - authorize the `Consumer Key` with the `Request Token` via the presented URL to get the `Verifier` code
18 | - enter the `Verifier code` to request an `Access Token`
19 | - store the `Access Token` in `access_token.php`.
20 |
21 | ## Sample scripts
22 |
23 | - ApiList-oauth1-pecl.php Shows your rate limiting data in JSON format.
24 | - CartAddModel-oauth1-pecl.php Add a model to your shopping cart.
25 | - CartList-oauth1-pecl.php Show your cart contents.
26 | - MaterialList-oauth1-pecl.php Show the list of all material properties.
27 | - MaterialInfo-oauth1-pecl.php Show material properties.
28 | - ModelDownload-oauth1-pecl.php Download a model.
29 | - ModelGet-oauth1-pecl.php Show model properties.
30 | - ModelUpdate-oauth1-pecl.php Update model properties.
31 | - ModelUpload-oauth1-pecl.php Upload a model.
32 | - PrinterList-oauth1-pecl.php Show a list of all properties of all printers.
33 | - PrinterGet-oauth1-pecl.php Show all properties of a printer.
34 |
35 | ## TODO
36 |
37 | -
38 |
--------------------------------------------------------------------------------
/dot-net/API Example/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("API_Example")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("API_Example")]
13 | [assembly: AssemblyCopyright("Copyright © 2014")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("b6a9995c-36d6-47b5-b47c-e1748b3ed5c3")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Revision and Build Numbers
33 | // by using the '*' as shown below:
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
36 |
--------------------------------------------------------------------------------
/php-pecl/ModelUpload-oauth1-pecl.php:
--------------------------------------------------------------------------------
1 | #!/usr/bin/php
2 | enableDebug();
12 | $oauth->setToken($access_token, $access_secret);
13 | } catch(OAuthException $E) {
14 | Error("setup exception", $E->getMessage(), null, null, $E->debugInfo, $E->getFile(), $E->getLine());
15 | }
16 |
17 | try {
18 | $filename = "cube-1cm3-centered_in_meter.stl";
19 | $file = file_get_contents("../models/". $filename);
20 | $data = array("fileName" => "$filename",
21 | "file" => rawurlencode(base64_encode($file)),
22 | "hasRightsToModel" => 1,
23 | "acceptTermsAndConditions" => 1,
24 | );
25 | $data_string = json_encode($data);
26 | $oauth->fetch($api_url_base ."/models/v1", $data_string, OAUTH_HTTP_METHOD_POST, array("Accept" => "application/json", "Content-Type" => "application/json"));
27 | $response = $oauth->getLastResponse();
28 | $json = json_decode($response);
29 | if (null == $json) {
30 | PrintJsonLastError();
31 | var_dump($response);
32 | } else {
33 | print_r($json);
34 | }
35 | } catch(OAuthException $E) {
36 | Error("fetch exception", $E->getMessage(), $oauth->getLastResponse(), $oauth->getLastResponseInfo(), $E->debugInfo, $E->getFile(), $E->getLine());
37 | }
38 |
39 | ?>
40 |
41 |
--------------------------------------------------------------------------------
/php-pecl/OrderReprint-oauth1-pecl.php:
--------------------------------------------------------------------------------
1 | #!/usr/bin/php
2 | enableDebug();
14 | $oauth->setToken($access_token, $access_secret);
15 | } catch(OAuthException $E) {
16 | Error("setup exception", $E->getMessage(), null, null, $E->debugInfo, $E->getFile(), $E->getLine());
17 | }
18 |
19 | try {
20 | $orderId = 1234567; //CHANGEME
21 |
22 | $data = array(
23 | "orderProductId" => 1234567, //CHANGEME
24 | "reprintReasonId" => 503, //CHANGEME
25 | "reprintComment" => "This needs to be at least 10 chars", //CHANGEME
26 | "quantity" => 1, //CHANGEME
27 | );
28 | $data_string = json_encode($data);
29 |
30 | $oauth->fetch($api_url_base . "/orders/$orderId/reprint/v1", $data_string, OAUTH_HTTP_METHOD_POST, array("Accept" => "application/json", "Content-Type" => "application/json"));
31 | $response = $oauth->getLastResponse();
32 | $json = json_decode($response);
33 |
34 | if (null == $json) {
35 | PrintJsonLastError();
36 | var_dump($response);
37 | } else {
38 | print_r($json);
39 | }
40 | } catch(OAuthException $E) {
41 | echo($E->lastResponse . "\n");
42 | Error("fetch exception", $E->getMessage(), $oauth->getLastResponse(), $oauth->getLastResponseInfo(), $E->debugInfo, $E->getFile(), $E->getLine());
43 | }
44 |
45 | ?>
46 |
47 |
--------------------------------------------------------------------------------
/php-pecl/ShapeJSCustomization-oauth1-pecl.php:
--------------------------------------------------------------------------------
1 | #!/usr/bin/php
2 | enableDebug();
12 | $oauth->setToken($access_token, $access_secret);
13 | } catch(OAuthException $E) {
14 | Error("setup exception", $E->getMessage(), null, null, $E->debugInfo, $E->getFile(), $E->getLine());
15 | }
16 |
17 | try {
18 | $text = "customText";
19 |
20 | $filename = "customPic.png";
21 | $picture = file_get_contents("../pictures/". $filename);
22 |
23 | $spin = "ABC123"; // CHANGEME // SPIN for a product that has already been set up as a custom maker product with one text field and one picture field
24 | $data = array(
25 | "spin" => "$spin",
26 | "customParam" => array(
27 | "text" => "$text",
28 | "picture" => rawurlencode(base64_encode($picture)),
29 | "pictureName" => $filename
30 | )
31 | );
32 |
33 | $data_string = json_encode($data);
34 | $oauth->fetch($api_url_base ."/shapejs/v1", $data_string, OAUTH_HTTP_METHOD_POST, array("Accept" => "application/json", "Content-Type" => "application/json"));
35 | $response = $oauth->getLastResponse();
36 | $json = json_decode($response);
37 | if (null == $json) {
38 | PrintJsonLastError();
39 | var_dump($response);
40 | } else {
41 | print_r($json);
42 | }
43 | } catch(OAuthException $E) {
44 | Error("fetch exception", $E->getMessage(), $oauth->getLastResponse(), $oauth->getLastResponseInfo(), $E->debugInfo, $E->getFile(), $E->getLine());
45 | }
46 |
47 | ?>
48 |
49 |
--------------------------------------------------------------------------------
/php-pecl/PriceModel-oauth1-pecl.php:
--------------------------------------------------------------------------------
1 | #!/usr/bin/php
2 | enableDebug();
13 | $oauth->setToken($access_token, $access_secret);
14 | } catch(OAuthException $E) {
15 | Error("setup exception", $E->getMessage(), null, null, $E->debugInfo, $E->getFile(), $E->getLine());
16 | }
17 |
18 | try {
19 | $volume = 1 / (100*100*100); # 1 cm^3 in m^2
20 | $area = 600 / (1000*1000); # 600 mm^2 (6 cm^2) in m^2
21 | $xBoundMin = 0;
22 | $yBoundMin = 0;
23 | $zBoundMin = 0;
24 | $xBoundMax = 0.01; # 1 cm in m
25 | $yBoundMax = 0.01;
26 | $zBoundMax = 0.01;
27 | $data = array("volume" => "$volume",
28 | "area" => $area,
29 | "xBoundMin" => $xBoundMin,
30 | "xBoundMax" => $xBoundMax,
31 | "yBoundMin" => $yBoundMin,
32 | "yBoundMax" => $yBoundMax,
33 | "zBoundMin" => $zBoundMin,
34 | "zBoundMax" => $zBoundMax,
35 | );
36 | $data_string = json_encode($data);
37 |
38 | $oauth->fetch($api_url_base ."/price/v1", $data_string, OAUTH_HTTP_METHOD_POST, array("Accept" => "application/json", "Content-Type" => "application/json"));
39 | $response = $oauth->getLastResponse();
40 | $json = json_decode($response);
41 | if (null == $json) {
42 | PrintJsonLastError();
43 | var_dump($response);
44 | } else {
45 | print_r($json);
46 | }
47 | } catch(OAuthException $E) {
48 | Error("fetch exception", $E->getMessage(), $oauth->getLastResponse(), $oauth->getLastResponseInfo(), $E->debugInfo, $E->getFile(), $E->getLine());
49 | }
50 |
51 | ?>
52 |
53 |
--------------------------------------------------------------------------------
/php-pecl/error.php:
--------------------------------------------------------------------------------
1 | on line <$line>";
11 | }
12 | echo "\n";
13 |
14 | if ($exception) {
15 | echo "Exception : $exception\n";
16 | }
17 |
18 | if($lastResponse) {
19 | echo "Error : ";
20 | $json = json_decode($lastResponse);
21 | if (null == $json) {
22 | PrintJsonLastError();
23 | var_dump($lastResponse);
24 | } else {
25 | print_r($json);
26 | }
27 | }
28 |
29 | if ($verbose_debug && $lastResponseInfo) {
30 | echo "\nQuery response headers :\n";
31 | var_dump($lastResponseInfo);
32 | }
33 |
34 | if ($verbose_debug && $debugInfo) {
35 | echo "\nOauth debugInfo :\n";
36 | var_dump($debugInfo);
37 | }
38 |
39 | exit(1);
40 | }
41 |
42 | function PrintJsonLastError() {
43 | switch (json_last_error()) {
44 | case JSON_ERROR_NONE:
45 | echo ' - No errors';
46 | break;
47 | case JSON_ERROR_DEPTH:
48 | echo ' - Maximum stack depth exceeded';
49 | break;
50 | case JSON_ERROR_STATE_MISMATCH:
51 | echo ' - Underflow or the modes mismatch';
52 | break;
53 | case JSON_ERROR_CTRL_CHAR:
54 | echo ' - Unexpected control character found';
55 | break;
56 | case JSON_ERROR_SYNTAX:
57 | echo ' - Syntax error, malformed JSON';
58 | break;
59 | case JSON_ERROR_UTF8:
60 | echo ' - Malformed UTF-8 characters, possibly incorrectly encoded';
61 | break;
62 | default:
63 | echo ' - Unknown error';
64 | break;
65 | }
66 | echo PHP_EOL;
67 | }
68 |
69 |
--------------------------------------------------------------------------------
/php-pecl/OrderPost-oauth1-pecl.php:
--------------------------------------------------------------------------------
1 | #!/usr/bin/php
2 | enableDebug();
14 | $oauth->setToken($access_token, $access_secret);
15 | } catch(OAuthException $E) {
16 | Error("setup exception", $E->getMessage(), null, null, $E->debugInfo, $E->getFile(), $E->getLine());
17 | }
18 |
19 | try {
20 |
21 | $items = array(
22 | array(
23 | 'modelId' => 1234, // CHANGEME
24 | 'materialId' => 95, // CHANGEME
25 | 'quantity' => 1,
26 | 'productDimensionChoiceCombo' => 0
27 | )
28 | );
29 |
30 | $data = array(
31 | "firstName" => "John", // CHANGEME
32 | "lastName" => "Doe", //CHANGEME
33 | "country" => "United States", //CHEANGEME
34 | "state" => "NY", //CHANGEME
35 | "city" => "New York", //CHANGEME
36 | "address1" => "123 Street Name", //CHANGEME
37 | "address2" => "Apt 1", //CHANGEME
38 | "address3" => "Company Name", //CHANGEME
39 | "zipCode" => "11111", //CHANGEME
40 | "phoneNumber" => "1111111111", //CHANGEME
41 | "items" => $items,
42 | "paymentVerificationId" => "ABCD", //CHANGEME - this id will be provided by Shapeways
43 | "paymentMethod" => "credit_card",
44 | "shippingOption" => "Cheapest"
45 | );
46 |
47 | $data_string = json_encode($data);
48 | $oauth->fetch($api_url_base ."/orders/v1", $data_string, OAUTH_HTTP_METHOD_POST, array("Accept" => "application/json", "Content-Type" => "application/json"));
49 | $response = $oauth->getLastResponse();
50 |
51 | $json = json_decode($response);
52 | if (null == $json) {
53 | PrintJsonLastError();
54 | var_dump($response);
55 | } else {
56 | print_r($json);
57 | }
58 |
59 | } catch(OAuthException $E) {
60 | Error("fetch exception", $E->getMessage(), $oauth->getLastResponse(), $oauth->getLastResponseInfo(), $E->debugInfo, $E->getFile(), $E->getLine());
61 | }
62 |
63 | ?>
64 |
65 |
--------------------------------------------------------------------------------
/php-pecl/Authorize-oauth1-pecl.php:
--------------------------------------------------------------------------------
1 | #!/usr/bin/php
2 | enableDebug();
13 | } catch(OAuthException $E) {
14 | Error("setup exception", $E->getMessage(), null, null, $E->debugInfo, $E->getFile(), $E->getLine());
15 | }
16 |
17 | try {
18 | $info = $oauth_client->getRequestToken("$api_url_base/oauth1/request_token/v1", "oob");
19 | # work around our Pecl getRequestToken->array bug https://bugs.php.net/bug.php?id=63572 :
20 | if ( array_key_exists('oauth_token_secret', $info) &&
21 | array_key_exists('authentication_url', $info) &&
22 | ! array_key_exists('oauth_token', $info)) {
23 | $urlArray = parse_url($info['authentication_url']);
24 | $info['authentication_url'] = $urlArray['scheme'] .'://'. $urlArray['host'] . $urlArray['path'];
25 | parse_str($urlArray['query']);
26 | $info['oauth_token'] = $oauth_token;
27 | }
28 | if ( array_key_exists('oauth_token', $info) &&
29 | array_key_exists('oauth_token_secret', $info) &&
30 | array_key_exists('authentication_url', $info) ) {
31 | echo "Request token : ".$info['oauth_token']."\n";
32 | echo "Request token secret : ".$info['oauth_token_secret']."\n";
33 | echo "Next please authenticate yourself at ".$info['authentication_url']."?oauth_token=".$info['oauth_token']." and collect the PIN for the next step.\n";
34 | $oauth_client->setToken( $info['oauth_token'] , $info['oauth_token_secret'] );
35 | } else {
36 | echo "Issue getting request token from Oauth client\n";
37 | return;
38 | }
39 | } catch(OAuthException $E){
40 | Error("getRequestToken", $E->getMessage(), $oauth_client->getLastResponse(), $oauth_client->getLastResponseInfo(), $E->debugInfo, $E->getFile(), $E->getLine());
41 | }
42 |
43 | $pin = readline("Pin: ");
44 |
45 | try {
46 | $info = $oauth_client->getAccessToken("$api_url_base/oauth1/access_token/v1", null, $pin);
47 | if ( array_key_exists('oauth_token', $info) &&
48 | array_key_exists('oauth_token_secret', $info) ) {
49 | echo "Access token : ".$info['oauth_token']."\n";
50 | echo "Access token secret : ".$info['oauth_token_secret']."\n";
51 | echo "\nYou can store these access token values in access_token.php for the other scripts to use.\n";
52 | $oauth_client->setToken( $info['oauth_token'] , $info['oauth_token_secret'] );
53 | } else {
54 | echo "Issue getting access token from Oauth client\n";
55 | return;
56 | }
57 | } catch(OAuthException $E){
58 | Error("getAccessToken exception", $E->getMessage(), $oauth_client->getLastResponse(), $oauth_client->getLastResponseInfo(), $E->debugInfo, $E->getFile(), $E->getLine());
59 | }
60 |
61 | ?>
62 |
63 |
--------------------------------------------------------------------------------
/dot-net/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.sln.docstates
8 |
9 | # Build results
10 | [Dd]ebug/
11 | [Dd]ebugPublic/
12 | [Rr]elease/
13 | x64/
14 | build/
15 | bld/
16 | [Bb]in/
17 | [Oo]bj/
18 |
19 | # MSTest test Results
20 | [Tt]est[Rr]esult*/
21 | [Bb]uild[Ll]og.*
22 |
23 | #NUNIT
24 | *.VisualState.xml
25 | TestResult.xml
26 |
27 | # Build Results of an ATL Project
28 | [Dd]ebugPS/
29 | [Rr]eleasePS/
30 | dlldata.c
31 |
32 | *_i.c
33 | *_p.c
34 | *_i.h
35 | *.ilk
36 | *.meta
37 | *.obj
38 | *.pch
39 | *.pdb
40 | *.pgc
41 | *.pgd
42 | *.rsp
43 | *.sbr
44 | *.tlb
45 | *.tli
46 | *.tlh
47 | *.tmp
48 | *.tmp_proj
49 | *.log
50 | *.vspscc
51 | *.vssscc
52 | .builds
53 | *.pidb
54 | *.svclog
55 | *.scc
56 |
57 | # Chutzpah Test files
58 | _Chutzpah*
59 |
60 | # Visual C++ cache files
61 | ipch/
62 | *.aps
63 | *.ncb
64 | *.opensdf
65 | *.sdf
66 | *.cachefile
67 |
68 | # Visual Studio profiler
69 | *.psess
70 | *.vsp
71 | *.vspx
72 |
73 | # TFS 2012 Local Workspace
74 | $tf/
75 |
76 | # Guidance Automation Toolkit
77 | *.gpState
78 |
79 | # ReSharper is a .NET coding add-in
80 | _ReSharper*/
81 | *.[Rr]e[Ss]harper
82 | *.DotSettings.user
83 |
84 | # JustCode is a .NET coding addin-in
85 | .JustCode
86 |
87 | # TeamCity is a build add-in
88 | _TeamCity*
89 |
90 | # DotCover is a Code Coverage Tool
91 | *.dotCover
92 |
93 | # NCrunch
94 | *.ncrunch*
95 | _NCrunch_*
96 | .*crunch*.local.xml
97 |
98 | # MightyMoose
99 | *.mm.*
100 | AutoTest.Net/
101 |
102 | # Web workbench (sass)
103 | .sass-cache/
104 |
105 | # Installshield output folder
106 | [Ee]xpress/
107 |
108 | # DocProject is a documentation generator add-in
109 | DocProject/buildhelp/
110 | DocProject/Help/*.HxT
111 | DocProject/Help/*.HxC
112 | DocProject/Help/*.hhc
113 | DocProject/Help/*.hhk
114 | DocProject/Help/*.hhp
115 | DocProject/Help/Html2
116 | DocProject/Help/html
117 |
118 | # Click-Once directory
119 | publish/
120 |
121 | # Publish Web Output
122 | *.[Pp]ublish.xml
123 | *.azurePubxml
124 |
125 | # NuGet Packages Directory
126 | packages/*
127 | ## TODO: If the tool you use requires repositories.config uncomment the next line
128 | #!packages/repositories.config
129 |
130 | # Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets
131 | # This line needs to be after the ignore of the build folder (and the packages folder if the line above has been uncommented)
132 | !packages/build/
133 |
134 | # Windows Azure Build Output
135 | csx/
136 | *.build.csdef
137 |
138 | # Windows Store app package directory
139 | AppPackages/
140 |
141 | # Others
142 | sql/
143 | *.Cache
144 | ClientBin/
145 | [Ss]tyle[Cc]op.*
146 | ~$*
147 | *~
148 | *.dbmdl
149 | *.dbproj.schemaview
150 | *.pfx
151 | *.publishsettings
152 | node_modules/
153 |
154 | # RIA/Silverlight projects
155 | Generated_Code/
156 |
157 | # Backup & report files from converting an old project file to a newer
158 | # Visual Studio version. Backup files are not needed, because we have git ;-)
159 | _UpgradeReport_Files/
160 | Backup*/
161 | UpgradeLog*.XML
162 | UpgradeLog*.htm
163 |
164 | # SQL Server files
165 | *.mdf
166 | *.ldf
167 |
168 | # Business Intelligence projects
169 | *.rdl.data
170 | *.bim.layout
171 | *.bim_*.settings
172 |
173 | # Microsoft Fakes
174 | FakesAssemblies/
175 |
176 | # =========================
177 | # Windows detritus
178 | # =========================
179 |
180 | # Windows image file caches
181 | Thumbs.db
182 | ehthumbs.db
183 |
184 | # Folder config file
185 | Desktop.ini
186 |
187 | # Recycle Bin used on file shares
188 | $RECYCLE.BIN/
189 |
--------------------------------------------------------------------------------
/dot-net/API Example/ShapewaysClient.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Net;
6 | using System.Runtime.Serialization;
7 | using System.Web;
8 | using OAuth;
9 | using Newtonsoft.Json;
10 |
11 | namespace API_Example
12 | {
13 | public class ShapewaysClient
14 | {
15 | private String consumerKey, consumerSecret, callback;
16 | public String OAuthToken, OAuthSecret;
17 |
18 | public ShapewaysClient(String consumerKey, String consumerSecret, String callback = "oob"){
19 | this.consumerKey = consumerKey;
20 | this.consumerSecret = consumerSecret;
21 | this.callback = callback;
22 | }
23 |
24 | public String connect()
25 | {
26 | OAuthRequest client = new OAuthRequest()
27 | {
28 | Method = "GET",
29 | Type = OAuthRequestType.RequestToken,
30 | SignatureMethod = OAuthSignatureMethod.HmacSha1,
31 | ConsumerKey = this.consumerKey,
32 | ConsumerSecret = this.consumerSecret,
33 | RequestUrl = "https://api.shapeways.com/oauth1/request_token/v1",
34 | Version = "1.0a",
35 | Realm = "shapeways.com",
36 | CallbackUrl = this.callback,
37 | };
38 | string auth = client.GetAuthorizationQuery();
39 | string url = client.RequestUrl + "?" + auth;
40 | HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
41 | HttpWebResponse response = (HttpWebResponse)request.GetResponse();
42 | string content = new StreamReader(response.GetResponseStream()).ReadToEnd();
43 | var result = HttpUtility.ParseQueryString(content);
44 | var authUrl = result.Get("authentication_url");
45 | this.OAuthToken = result.Get("oauth_token");
46 | this.OAuthSecret = result.Get("oauth_token_secret");
47 | response.Close();
48 | return authUrl;
49 | }
50 |
51 | public void verifyUrl(string url)
52 | {
53 | var qsParams = HttpUtility.ParseQueryString(url);
54 | var token = qsParams.Get("oauth_token");
55 | var verifier = qsParams.Get("oauth_verifier");
56 | OAuthRequest client = new OAuthRequest()
57 | {
58 | Method = "GET",
59 | Type = OAuthRequestType.AccessToken,
60 | SignatureMethod = OAuthSignatureMethod.HmacSha1,
61 | ConsumerKey = this.consumerKey,
62 | ConsumerSecret = this.consumerSecret,
63 | RequestUrl = "https://api.shapeways.com/oauth1/access_token/v1",
64 | Version = "1.0a",
65 | Realm = "shapeways.com",
66 | TokenSecret = this.OAuthSecret,
67 | Token = token,
68 | Verifier = verifier,
69 | };
70 | string auth = client.GetAuthorizationQuery();
71 | string requestUrl = client.RequestUrl + "?" + auth;
72 | HttpWebRequest request = (HttpWebRequest)WebRequest.Create(requestUrl);
73 | HttpWebResponse response = (HttpWebResponse)request.GetResponse();
74 | string content = new StreamReader(response.GetResponseStream()).ReadToEnd();
75 | var result = HttpUtility.ParseQueryString(content);
76 | this.OAuthToken = result.Get("oauth_token");
77 | this.OAuthSecret = result.Get("oauth_token_secret");
78 | }
79 |
80 | public object getApiInfo()
81 | {
82 | OAuthRequest client = new OAuthRequest()
83 | {
84 | Method = "GET",
85 | Type = OAuthRequestType.ProtectedResource,
86 | SignatureMethod = OAuthSignatureMethod.HmacSha1,
87 | ConsumerKey = this.consumerKey,
88 | ConsumerSecret = this.consumerSecret,
89 | RequestUrl = "https://api.shapeways.com/api/v1",
90 | Version = "1.0a",
91 | Realm = "shapeways.com",
92 | TokenSecret = this.OAuthSecret,
93 | Token = this.OAuthToken,
94 | };
95 | string auth = client.GetAuthorizationQuery();
96 | string requestUrl = client.RequestUrl + "?" + auth;
97 | HttpWebRequest request = (HttpWebRequest)WebRequest.Create(requestUrl);
98 | HttpWebResponse response = (HttpWebResponse)request.GetResponse();
99 | string content = new StreamReader(response.GetResponseStream()).ReadToEnd();
100 | return JsonConvert.DeserializeObject(content);
101 | }
102 |
103 | }
104 | }
--------------------------------------------------------------------------------
/php-curl/AuthorizeWithRequestUriQuery-oauth1-curl.php:
--------------------------------------------------------------------------------
1 | #!/usr/bin/php
2 | $value){
12 | $r[] = "$consumer_key=" . rawurlencode($value);
13 | }
14 | return $method .'&'. rawurlencode($baseURI) .'&'. rawurlencode(implode('&', $r));
15 | }
16 |
17 | function buildAuthorizationHeader($oauth) {
18 | $r = 'Authorization: OAuth ';
19 | $values = array();
20 | foreach($oauth as $consumer_key=>$value)
21 | $values[] = "$consumer_key=\"" . rawurlencode($value) . "\"";
22 | $r .= implode(', ', $values);
23 | return $r;
24 | }
25 |
26 | # Use http://tools.ietf.org/html/rfc5849#section-3.5.3
27 |
28 | echo "Using consumer key :\n";
29 | echo "Consumer Key : ".$consumer_key."\n";
30 | echo "Consumer Key secret : ".$consumer_secret."\n";
31 | echo "To request a temporary request token.\n";
32 | echo "\n";
33 |
34 | # Get a request token
35 | $link = "/oauth1/request_token/v1";
36 | $timestamp = time();
37 | $signature_method="HMAC-SHA1";
38 | $oauth = array(
39 | 'oauth_consumer_key' => $consumer_key,
40 | 'oauth_nonce' => time(),
41 | 'oauth_signature_method' => $signature_method,
42 | 'oauth_timestamp' => $timestamp,
43 | 'oauth_version' => '1.0',
44 | );
45 | $url = $api_url_base . $link;
46 | $base_info = buildBaseString($url, 'GET', $oauth);
47 | $composite_key = rawurlencode($consumer_secret) . '&' . rawurlencode(null);
48 | $oauth_signature = base64_encode(hash_hmac('sha1', $base_info, $composite_key, true));
49 | $oauth['oauth_signature'] = $oauth_signature;
50 |
51 | $oauthString = "";
52 | foreach($oauth as $key=>$value) {
53 | $stringKey = rawurlencode($key);
54 | $stringValue = rawurlencode($value);
55 | if (strlen($oauthString) == 0) {
56 | $oauthString .= "?";
57 | } else {
58 | $oauthString .= "&";
59 | }
60 | $oauthString .= "$stringKey=$stringValue";
61 | }
62 |
63 | $url .= $oauthString;
64 |
65 | $options = array(
66 | CURLOPT_HEADER => false,
67 | CURLOPT_URL => $url,
68 | CURLOPT_PORT => 80,
69 | CURLOPT_RETURNTRANSFER => true);
70 | $ch = curl_init();
71 | curl_setopt_array($ch, $options);
72 | $result = curl_exec($ch);
73 | if ( ! $result ) {
74 | echo "Curl error :\n". curl_error($ch) . "\n";
75 | exit(1);
76 | } else {
77 | $oauth_token="";
78 | $oauth_token_secret="";
79 | $resultArray=parse_url(rawurldecode($result));
80 | parse_str($resultArray["path"]);
81 | parse_str($resultArray["query"]);
82 |
83 | echo "Received a temporary request token :\n";
84 | echo "Request token : ".$oauth_token."\n";
85 | echo "Request token secret : ".$oauth_token_secret."\n";
86 | echo "\n";
87 | echo "Next please authenticate yourself at ".$authentication_url."?oauth_token=".$oauth_token." and collect the PIN for the next step.\n";
88 | echo "\n";
89 | }
90 | curl_close($ch);
91 |
92 | $pin = readline("Pin: ");
93 |
94 | # Get an access token
95 | echo "\nRequesting an access token.\n";
96 | $link = "/oauth1/access_token/v1";
97 |
98 | $timestamp = time();
99 | $signature_method="HMAC-SHA1";
100 | unset($oauth);
101 | $oauth = array(
102 | 'oauth_consumer_key' => $consumer_key,
103 | 'oauth_signature_method' => $signature_method,
104 | 'oauth_nonce' => time(),
105 | 'oauth_timestamp' => $timestamp,
106 | 'oauth_version' => '1.0',
107 | 'oauth_token' => $oauth_token,
108 | 'oauth_verifier' => $pin,
109 | );
110 | $url = $api_url_base . $link;
111 | $base_info = buildBaseString($url, 'GET', $oauth);
112 | $composite_key = rawurlencode($consumer_secret) . '&' . rawurlencode($oauth_token_secret);
113 | $oauth_signature = base64_encode(hash_hmac('sha1', $base_info, $composite_key, true));
114 | $oauth['oauth_signature'] = $oauth_signature;
115 |
116 | $oauthString = "";
117 | foreach($oauth as $key=>$value) {
118 | $stringKey = rawurlencode($key);
119 | $stringValue = rawurlencode($value);
120 | if (strlen($oauthString) == 0) {
121 | $oauthString .= "?";
122 | } else {
123 | $oauthString .= "&";
124 | }
125 | $oauthString .= "$stringKey=$stringValue";
126 | }
127 |
128 | $url .= $oauthString;
129 |
130 | $options = array(
131 | CURLOPT_HEADER => false,
132 | CURLOPT_URL => $url,
133 | CURLOPT_PORT => 80,
134 | CURLOPT_RETURNTRANSFER => true);
135 | $ch = curl_init();
136 | curl_setopt_array($ch, $options);
137 | $result = curl_exec($ch);
138 | if ( ! $result ) {
139 | echo "Curl error :\n". curl_error($ch) . "\n";
140 | } else {
141 | $oauth_token="";
142 | $oauth_token_secret="";
143 | $resultArray=parse_url(rawurldecode($result));
144 | parse_str($resultArray["path"]);
145 | parse_str($resultArray["query"]);
146 | echo "\nReceived an access token :\n";
147 | echo "Access token : ".$oauth_token."\n";
148 | echo "Access token secret : ".$oauth_token_secret."\n";
149 | echo "\nYou can store these access token values in access_token.php for the other scripts to use.\n";
150 | }
151 | curl_close($ch);
152 |
153 |
--------------------------------------------------------------------------------
/dot-net/API Example/API Example.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 |
8 |
9 | 2.0
10 | {94A6E38F-1585-4485-A7B7-6BFE89E03252}
11 | {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}
12 | Library
13 | Properties
14 | API_Example
15 | API Example
16 | v4.5
17 | true
18 |
19 |
20 |
21 |
22 |
23 |
24 | true
25 | full
26 | false
27 | bin\
28 | DEBUG;TRACE
29 | prompt
30 | 4
31 |
32 |
33 | pdbonly
34 | true
35 | bin\
36 | TRACE
37 | prompt
38 | 4
39 |
40 |
41 |
42 |
43 | ..\packages\Newtonsoft.Json.6.0.1\lib\net45\Newtonsoft.Json.dll
44 |
45 |
46 | ..\packages\OAuth.1.0.3\lib\net40\OAuth.dll
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 | Web.config
69 |
70 |
71 | Web.config
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 | Callback.aspx
83 | ASPXCodeBehind
84 |
85 |
86 | Callback.aspx
87 |
88 |
89 | Default.aspx
90 | ASPXCodeBehind
91 |
92 |
93 | Default.aspx
94 |
95 |
96 | Login.aspx
97 | ASPXCodeBehind
98 |
99 |
100 | Login.aspx
101 |
102 |
103 |
104 |
105 |
106 | 10.0
107 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 | True
117 | True
118 | 49314
119 | /
120 | http://localhost:49314/
121 | False
122 | False
123 |
124 |
125 | False
126 |
127 |
128 |
129 |
130 |
137 |
--------------------------------------------------------------------------------