How to upload multiple blog posts in BlogSpot at once? - python

I have completely write 86 blog posts. I tried to upload it manually but seems like a long process, so I decided to make it by xml file and worked on it but no xml format on web helps me. This is the code I tried with,
<?xml version='1.0' encoding='UTF-8'?>
<ns0:feed xmlns:ns0="http://www.w3.org/2005/Atom">
<ns0:generator>Blogger</ns0:generator>
<ns0:entry>
<ns0:category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/blogger/2008/kind#post" />
<ns0:category scheme="http://www.blogger.com/atom/ns#" term="CATEGORY A" />
<ns0:id>BLOGGER TEST</ns0:id>
<ns0:content type="html">Blogger CONTENT</ns0:content>
<ns0:title type="html">BLOGGER TITLE</ns0:title>
</ns0:entry>
</ns0:feed>
If using xml is bad choice then any chance in python or any other coding.

Use the API as in the example below
POST https://www.googleapis.com/blogger/v3/blogs/8070105920543249955/posts/
Authorization: /* OAuth 2.0 token here */
Content-Type: application/json
{
"kind": "blogger#post",
"blog": {
"id": "8070105920543249955"
},
"title": "A new post",
"content": "With <b>exciting</b> content..."
}
See here for more:
https://developers.google.com/blogger/docs/3.0/using#AddingAPost

You can add a post for a blog by sending a POST request to the post-collection URI with a post JSON body:
https://www.googleapis.com/blogger/v3/blogs/YOUR_BLOG_ID/posts/
Request (You must be authenticated to create a post) :
POST https://www.googleapis.com/blogger/v3/blogs/8070105920543249955/posts/
Authorization: /* OAuth 2.0 token here */
Content-Type: application/json
{
"kind": "blogger#post",
"blog": {
"id": "8070105920543249955"
},
"title": "A new post",
"content": "With <b>exciting</b> content..."
}
Response (If your request is successful, you will get an HTTP 200 OK status) :
{
"kind": "blogger#post",
"id": "6819100329896798058",
"blog": {
"id": "8070105920543249955"
},
"published": "2012-05-20T20:08:00-07:00",
"updated": "2012-05-20T20:08:35-07:00",
"url": "http://brettmorgan-test2.blogspot.com/2012/05/new-post.html",
"selfLink": "https://www.googleapis.com/blogger/v3/blogs/8070105920543249955/posts/6819100329896798058",
"title": "A new post",
"content": "With <b>exciting</b> content...",
"author": {
"id": "16258312240222542576",
"displayName": "Brett Morgan",
"url": "http://www.blogger.com/profile/16258312240222542576",
"image": {
"url": "https://resources.blogblog.com/img/b16-rounded.gif"
}
},
"replies": {
"totalItems": "0",
"selfLink": "https://www.googleapis.com/blogger/v3/blogs/8070105920543249955/posts/6819100329896798058/comments"
}
}
For more details please you can read the API doc.
https://developers.google.com/blogger/docs/3.0/using

Related

AVRO - JSON Enconding of messages in Confluent Python SerializingProducer vs. Confluent Rest Proxy with UNIONS

attached an example AVRO-Schema
{
"type": "record",
"name": "DummySampleAvroValue",
"namespace": "de.company.dummydomain",
"fields": [
{
"name": "ID",
"type": "int"
},
{
"name": "NAME",
"type": [
"null",
"string"
]
},
{
"name": "STATE",
"type": "int"
},
{
"name": "TIMESTAMP",
"type": [
"null",
"string"
]
}
]
}
Regarding the section "JSON Encoding" of the official AVRO-Specs - see: https://avro.apache.org/docs/current/spec.html#json_encoding - a JSON Message which validates against the above AVRO-Schema should look like the following because of the UNION-Types used:
{
"ID":1,
"NAME":{
"string":"Kafka"
},
"STATE":-1,
"TIMESTAMP":{
"string":"2022-04-28T10:57:03.048413"
}
}
When producing this message via Confluent Rest Proxy (AVRO), everything works fine, the data is accepted, validated and present in Kafka.
When using the "SearializingProducer" from the confluent_kafka Python Package, the example message is not accepted and only "regular" JSON works, e. g.:
{
"ID":1,
"NAME":"Kafka",
"STATE":-1,
"TIMESTAMP":"2022-04-28T10:57:03.048413"
}
Is this intended behaviour or am I doing something wrong? Can I tell the SerializingProducer to accept this encoding?
I need to hold open both ways to produce messages but the sending system can/want´s only to provide one of the above Payloads. Is there a way to use both with the same payload?
Thanks in advance.
Best regards

I am getting an error while using Python YouTube API

I am trying to create a Python program to get channel statisitics, but when I run it the YouTube API website gives this output (error):
{
"error": {
"code": 400,
"message": "'statisitcs'",
"errors": [
{
"message": "'statisitcs'",
"domain": "youtube.part",
"reason": "unknownPart",
"location": "part",
"locationType": "parameter"
}
]
}
}
This is my code:
class YTstats:
def __init__(self, api_key, channel_id):
self.api_key = api_key
self.channel_id = channel_id
self.channel_stats = None
def get_channel_statistics(self):
url = f'https://www.googleapis.com/youtube/v3/channels?part=statisitcs&id={self.channel_id}&key={self.api_key}'
print(url)
API_KEY = 'I cannot share my api key so I am not showing it but it is in my code'
yt = YTstats(API_KEY, 'UCbXgNpp0jedKWcQiULLbDTA')
yt.get_channel_statistics()
This problem is fixed now (it was a typo)
You have a typo here part=statisitcs - as you mentioned in your comment - and after looking closely to the code you provided in your question.
Next time, check closely your code and try to replicate the error using the try-it demo feature in the YouTube Data API documentation.
I do get the statistics of the channel_id you provided - that is: UCbXgNpp0jedKWcQiULLbDTA:
These are their statistics:
"statistics": {
"viewCount": "5642720",
"subscriberCount": "98400",
"hiddenSubscriberCount": false,
"videoCount": "158"
}
}
See the demo here.
Here is the full response:
{
"kind": "youtube#channelListResponse",
"etag": "lG-nYlbLnN81gtjVKe1zKPW6v7A",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 5
},
"items": [
{
"kind": "youtube#channel",
"etag": "j4Fo8qKbWrLHnQYB8sCI8_I4v9A",
"id": "UCbXgNpp0jedKWcQiULLbDTA",
"snippet": {
"title": "Python Engineer",
"description": "Free Python and Machine Learning Tutorials!\n\nHi, I'm Patrick. I’m a passionate Software Engineer who loves Machine Learning, Computer Vision, and Data Science. I create free content in order to help more people get into those fields. If you have any questions, feedback, or comments, just shoot me a message! I am happy to talk to you :)\n\nIf you like my content, please subscribe to the channel!\n\nPlease check out my website for more information:\nhttps://www.python-engineer.com\n\nIf you find these videos useful and would like to support my work you can find me on Patreon:\nhttps://www.patreon.com/patrickloeber\n\nLegal: https://www.python-engineer.com/legal-notice/\n",
"customUrl": "pythonengineer",
"publishedAt": "2019-05-03T11:22:33Z",
"thumbnails": {
"default": {
"url": "https://yt3.ggpht.com/ytc/AKedOLTs-Pvd4mvUi-m2rDLd8bzrKwS5a8C9HnDbkUDzHw=s88-c-k-c0x00ffffff-no-rj",
"width": 88,
"height": 88
},
"medium": {
"url": "https://yt3.ggpht.com/ytc/AKedOLTs-Pvd4mvUi-m2rDLd8bzrKwS5a8C9HnDbkUDzHw=s240-c-k-c0x00ffffff-no-rj",
"width": 240,
"height": 240
},
"high": {
"url": "https://yt3.ggpht.com/ytc/AKedOLTs-Pvd4mvUi-m2rDLd8bzrKwS5a8C9HnDbkUDzHw=s800-c-k-c0x00ffffff-no-rj",
"width": 800,
"height": 800
}
},
"localized": {
"title": "Python Engineer",
"description": "Free Python and Machine Learning Tutorials!\n\nHi, I'm Patrick. I’m a passionate Software Engineer who loves Machine Learning, Computer Vision, and Data Science. I create free content in order to help more people get into those fields. If you have any questions, feedback, or comments, just shoot me a message! I am happy to talk to you :)\n\nIf you like my content, please subscribe to the channel!\n\nPlease check out my website for more information:\nhttps://www.python-engineer.com\n\nIf you find these videos useful and would like to support my work you can find me on Patreon:\nhttps://www.patreon.com/patrickloeber\n\nLegal: https://www.python-engineer.com/legal-notice/\n"
}
},
"contentDetails": {
"relatedPlaylists": {
"likes": "",
"uploads": "UUbXgNpp0jedKWcQiULLbDTA"
}
},
"statistics": {
"viewCount": "5642720",
"subscriberCount": "98400",
"hiddenSubscriberCount": false,
"videoCount": "158"
}
}
]
}
Try to wait a few minutes after the call you made - probably, the API couldn't retrieve the data you requested due to excessive requests or the channel itself didn't have their statistics publicly available.

Python flask API POST request - JSON data after key

I'm very new to development, I'm writing a Python Flask app which is executing a POST request to log a new ticket on a system, I just need someone to verify how I structure this request as I'm really not sure.
The documentation says, for example:
curl api/v3/requests
-X POST
-H "Accept: application/vnd.manageengine.sdp.v3+json"
-H "Authorization: Zoho-Oauthtoken 1000.7xxx98976ab0xxxxxx19901e7551be57.bxxxx921ed64c04f79622bebcfxxxxxx"
-H "Content-Type: application/x-www-form-urlencoded"
-d input_data= '{
"request": {
"subject": "Need an External Monitor",
"resolution": {
"add_to_linked_requests": false,
"content": "The following is the resolution to the above request"
}
}
It's expecting input_data key, followed by the JSON array of info to submit.
The documentation is (here)
My code:
#app.route("/log", methods=["GET"])
def log():
"""Fetching a protected resource using an OAuth 2 token.
"""
servicedesk = OAuth2Session(client_id, token=session['oauth_token'])
headers = {"Authorization": "Bearer " + token, "Accept": "application/vnd.manageengine.sdp.v3+json", "Content-Type": "application/x-www-form-urlencoded"}
data = {
"request": {
"subject": "New Incident",
"mode": {
"name": "E-Mail",
},
"group": {
"name": "Incident"
},
"requester": {
"name": "Sarah Curtis Test"
},
"status": {
"name": "Open",
},
"template": {
"name": "Report an Incident"
},
"request_type": {
"name": "Incident",
},
"description": "This is a test. please ignore",
"category": {
"name": "Incident"
}
}
}
requests.post('https://sdpondemand.manageengine.eu/api/v3/requests?input_data=', data=data, headers=headers)
I don't have access to logs on the server to see what it is receiving either as it's a cloud service (unless there's a way to echo back the original raw POST request?)
The ticket isn't being logged when I try and do so via my app. It does work through Postman app to test the API request, when I add the JSON above into the x-www-form-urlencoded section on the body tab and put input_data into the key.
I need to know how to structure the POST request in my code. Any help appreciated! Thanks

How to send pushes with python using CleverTap API?

I am in the process of migrating my Parse push notification data to CleverTap. The problem that I am having is that the documentation is not very good about it and the examples that they give don't cover push notifications.
Anyone have an example of how to send pushes with CleverTap API using Python or at least evidence that this is possible?
The documentation now covers how to migrate your Parse installations to CleverTap. For example, say we are creating a push notification to be sent to users subscribed to the "yankees" and "mets" channels.
curl -H "Content-Type:application/json"
-H "X-CleverTap-Account-ID: Your CleverTap Account ID"
-H "X-CleverTap-Passcode: Your CleverTap Account Passcode"
--data "#payload"
"https://api.clevertap.com/1/targets/create.json"
Payload
"name": "My API Campaign",
"where": {
"common_profile_prop": {
"profile_fields": [
{
"name": "channels",
"value": ["yankees", "mets"]
}
]
}
},
"content":{
"title": "Breaking News",
"body": "Yankees Win 5-4",
"platform_specific": {
"ios": {
"deep_link": "example.com",
"sound_file": "example.caf",
"category": "reactive",
"badge_count": 1,
"key": "value_ios"
},
"android": {
"background_image": "http://example.jpg",
"default_sound": true,
"deep_link": "example.com",
"key": "value_android"
}
}
},
"devices": [
"android",
"ios",
],
"when": "now"
}
Response
{
"status": "success",
"id": 1457433898,
"estimates": {
"android": 90,
"ios": 300
}
}
Hope this helps. More documentation can be found here -
https://github.com/CleverTap/parse-migrate

PayPal doesn't return an authorization id

This is my first time with paypal and I need some help to finish payment integration. I've already tried to contact the paypal support but with no success. Here is my question and I really hope to get some help.
Something very strange grinds my gears and I cannot find why this do that. It's about the user authorization, and specially about paypal json responses. I'm using python sdk but that doesn't matter in this case. Here is my input.
paypalrestsdk.configure({
'mode': 'sandbox',
'client_id': 'XXX',
'client_secret': 'XXX'
})
payment = paypalrestsdk.Payment({
"intent": "authorize",
"payer": {
"payment_method": "paypal"
},
"redirect_urls": {
"return_url": "http://mysite/success",
"cancel_url": "http://mysite/cancel"
},
"transactions": [ {
"amount": {
"total": price,
"currency": "USD"
},
"description": title
}]
})
And everything is ОК, except that I doesn't receive an Authorization ID. Here is what I receive as response:
{
'redirect_urls':{
'cancel_url':'http://glamfame.com:8000/cancel',
'return_url':'http://glamfame.com:8000/success'
},
'update_time':'2014-04-08T13:54:22Z',
'state':'created',
'transactions':[
{
'amount':{
'currency':'USD',
'total':'123.00',
'details':{
'subtotal':'123.00'
}
},
'description':'fawfwa',
'related_resources':[{
'authorization':{
'valid_until':'2014-05-07T13:54:22Z',
'update_time':'2014-04-08T13:54:22Z',
'parent_payment':'PAY-54Y91315F8620142DKNB77DQ',
'create_time':'2014-04-08T13:54:22Z',
'links':[{
'method':'GET',
[link removed]
'rel':'parent_payment'
}]
}
}]
}],
'payer':{
'payer_info':{
'shipping_address':{
}
},
'payment_method':'paypal'
},
'id':'PAY-54Y91315F8620142DKNB77DQ',
'intent':'authorize',
'create_time':'2014-04-08T13:54:22Z',
'links':[{ POST, GET, REDIRECT methods with links
}]
And below is what I supposed to receive according their documentation.
{
"id": "2DC87612EK520411B",
"create_time": "2013-06-25T21:39:15Z",
"update_time": "2013-06-25T21:39:17Z",
"state": "authorized",
"amount": {
"total": "7.47",
"currency": "USD",
"details": {
"subtotal": "7.47"
}
},
"parent_payment": "PAY-36246664YD343335CKHFA4AY",
"valid_until": "2013-07-24T21:39:15Z",
"links": [
{
"href": [link removed]
"rel": "self",
"method": "GET"
},
{
"href": [link removed]
"rel": "capture",
"method": "POST"
},
{
"href": [link removed]
"rel": "void",
"method": "POST"
},
{
"href": [link removed]
"rel": "parent_payment",
"method": "GET"
}]
}
As you maybe already noticed, in the paypal response doesn't contain authorization id and void, and capture link. Can you please help me to find out the reason for this. Thank you in advance.
Best Regards,
Georgi
From the REST API documentation: With PayPal payments authorizations, PayPal initially provides HATEOAS links that are specific to PayPal payments including an approval_url and execute link. First get payment approval and execute the payment as you normally would do for a PayPal payment. Once you successfully execute on the payment authorization, PayPal responds with a new set of HATEOAS links, including a capture link that you use to capture the payment.

Categories