Created
December 12, 2013 18:35
-
-
Save wegrata/7933042 to your computer and use it in GitHub Desktop.
sample code to publish to LR
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
import requests | |
import json | |
from pprint import pprint | |
data = { | |
"documents": [{ | |
"doc_type": "resource_data", | |
"resource_locator": "https://www.example.com", | |
"resource_data": { | |
"copyrightYear": "2013", | |
"interactivityType": "expositive", | |
"name": "Test for Learning Registry", | |
"inLanguage": ["eng"], | |
"url": "https://www.example.com", | |
"author": [ | |
"John Jameson", | |
"James Johnson" | |
], | |
"publisher": "Gotham Press", | |
"isFamilyFriendly": True, | |
"numberOfPages": 100, | |
"datePublished": "2013-12-10", | |
"@type": "http://schema.org/Movie", | |
"learningResourceType": "Movie", | |
"audience": { | |
"educationalRole": "student", | |
"@type": "http://schema.org/EducationalAudience" | |
}, | |
"typicalAgeRange": ["18-19", "21-22", "19-20", "20-21"], | |
"keywords": ["Test data"], | |
"useRightsUrl": "http://www.example.org/TOS", | |
"@id": "https://www.example.org", | |
"provider": "LR.org", | |
"description": "This is a test entry for integration test purposes only." | |
}, | |
"keys": ["Test data"], | |
"TOS": { | |
"submission_TOS": "http://www.learningregistry.org/tos/cc0/v0-5/" | |
}, | |
"resource_data_type": "metadata", | |
"payload_placement": "inline", | |
"payload_schema": ["JSON-LD"], | |
"doc_version": "0.23.0", | |
"active": True, | |
"identity": { | |
"submitter": "LR.org", | |
"submitter_type": "agent" | |
} | |
} | |
] | |
} | |
creds = ("wgrata@problemsolutions.net", "password") | |
resp = requests.post("http://sandbox.learningregistry.org/publish", data=json.dumps(data), auth=creds) | |
pprint(resp.json()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment