50 lines
1.7 KiB
Python
50 lines
1.7 KiB
Python
|
#!/usr/bin/env python3
|
||
|
|
||
|
import requests
|
||
|
import json
|
||
|
|
||
|
# Define your JSON object
|
||
|
my_json = {'name': 'John', 'age': 30, 'city': 'New York'}
|
||
|
|
||
|
# Define the API endpoints for the services you want to use
|
||
|
gist_url = 'https://api.github.com/gists'
|
||
|
hastebin_url = 'https://hastebin.com/documents'
|
||
|
pastie_url = 'https://pastie.io/documents'
|
||
|
ghostbin_url = 'https://ghostbin.com/paste/new'
|
||
|
codepad_url = 'https://codepad.co/snippet_api'
|
||
|
termbin_url = 'https://termbin.com/documents'
|
||
|
|
||
|
# Define a function to upload the JSON object to each service
|
||
|
def upload_to_service(url, data):
|
||
|
response = requests.post(url, json=data)
|
||
|
if response.status_code == 200:
|
||
|
return response.json().get('key') or response.json().get('id')
|
||
|
else:
|
||
|
return None
|
||
|
|
||
|
# Upload the JSON object to each service and print the URLs
|
||
|
gist_key = upload_to_service(gist_url, {'public': True, 'files': {'my_json.json': {'content': json.dumps(my_json)}}})
|
||
|
if gist_key:
|
||
|
print(f'Gist URL: https://gist.github.com/{gist_key}')
|
||
|
|
||
|
hastebin_key = upload_to_service(hastebin_url, json.dumps(my_json))
|
||
|
if hastebin_key:
|
||
|
print(f'Hastebin URL: https://hastebin.com/{hastebin_key}.json')
|
||
|
|
||
|
pastie_key = upload_to_service(pastie_url, json.dumps(my_json))
|
||
|
if pastie_key:
|
||
|
print(f'Pastie URL: https://pastie.io/{pastie_key}')
|
||
|
|
||
|
ghostbin_key = upload_to_service(ghostbin_url, {'text': json.dumps(my_json)})
|
||
|
if ghostbin_key:
|
||
|
print(f'Ghostbin URL: https://ghostbin.com/{ghostbin_key}')
|
||
|
|
||
|
codepad_key = upload_to_service(codepad_url, {'code': json.dumps(my_json)})
|
||
|
if codepad_key:
|
||
|
print(f'Codepad URL: https://codepad.co/{codepad_key}.json')
|
||
|
|
||
|
termbin_key = upload_to_service(termbin_url, json.dumps(my_json))
|
||
|
if termbin_key:
|
||
|
print(f'Termbin URL: https://termbin.com/{termbin_key}')
|
||
|
|