Created
July 13, 2012 11:01
-
-
Save cedricpinson/3104276 to your computer and use it in GitHub Desktop.
sketchfab api
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
# -*- coding: utf-8 -*- | |
require "uri" | |
require "net/https" | |
require "base64" | |
require 'rubygems' | |
require "json" | |
screenshot="../data/thumbnail.png" | |
filename="../data/model.dae" | |
description="Test of the api with a simple model" | |
token_api="FF00FF" | |
title="Uber Glasses" | |
tags="test collada glasses" | |
url="https://api.sketchfab.com/model" | |
model_contents = Base64.encode64(File.read(filename)) | |
model_thumbnail = Base64.encode64(File.read(screenshot)) | |
data = { | |
'title'=> title, | |
'description'=> description, | |
'contents'=> model_contents, | |
'filename'=> filename, | |
'tags'=> tags, | |
'thumbnail'=> model_thumbnail, | |
'token'=> token_api | |
} | |
uri = URI.parse(url) | |
p uri | |
http = Net::HTTP.new(uri.host, uri.port) | |
http.use_ssl = true | |
request = Net::HTTP::Post.new(uri.request_uri, initheader = {'Content-Type' =>'application/json'}) | |
request.body = data.to_json | |
#data.to_json | |
response = http.request(request) | |
p response.body |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment