Google Classroom How To Post Image - google-classroom

How can I post an image or simple text on the Google Classroom with python (with or without API)?
I've tried to see reference but didn't find anything with python.

Here you can see the documentation. You must inform path parameter courseId and body, something like that:
{
"materials": [
{
"youtubeVideo": {
"id": "w4TJmrOVas4"
}
}
],
"text": "Students: see link for my new neurohealth class."
}

Related

Google People API notes field

I'd like to know how to get the 'notes' field from the Google people API. There's no equivalent in documentation. I tried "biographies" but that didn't return any notes when I called the API for names, emails, etc.
I've seen this question asked a few years ago but I know the API has changed a bit and was hoping someone knows the answer.
Thanks!
Answer
The biographies field still representing the notes
How to check it?
Create a contact setting the notes with a concrete string, i.e. Hey, I'am a note
Call people.connections.list
resourceName = people/me
personFields = names
Get the resourceName to use it later
Call people.get
resourceName = resource from point 3
personFields = biographies
Check the biographies field, it will look something like:
"biographies": [
{
"metadata": {
"primary": true,
"source": {
"type": "CONTACT",
"id": "randomId"
}
},
"value": "Hey, I'am a note",
"contentType": "TEXT_PLAIN"
}
References
people.connections.list
people.get

How to replace all hyperlinks using google slides api?

Referring to the Google slides api official documentation couldn't find a way to replace all links.
I found one work around: Google Slides API: replaceAllLinks?
I am able to replace text, images but not links.
Any help shall be greatly appreciated!
The hyperlink URL is represented by the link field of TextStyle.
This Link contains the field url, which refers to the URL this is pointing to. You should update this field when calling UpdateTextStyleRequest.
As an example, your request body could be something like:
{
"requests": [
{
"updateTextStyle": {
"objectId": "your_object_id",
"style": {
"link": {
"url": "your_new_url"
}
}
}
}
]
}

How to get name/confidence individually from classify_text?

Most of the other methods in the language api, such as analyze_syntax, analyze_sentiment etc, have the ability to return the constituent elements like
sentiment.score
sentiment.magnitude
token.part_of_speech.tag
etc etc etc....
but I have not found a way to return name and confidence in isolation from classify_text. It doesn't look like it's possible but that seems weird. Am missing something? Thanks
The language.documents.classifyText method returns a ClassificationCategory object which contains name and confidence. If you only want one of the fields you can filter by categories/name or categories/confidence. As an example I executed:
POST https://language.googleapis.com/v1/documents:classifyText?fields=categories%2Fname&key={YOUR_API_KEY}
{
"document": {
"content": "this is a test for a StackOverflow question. I get an error because I need more words in the document and I don't know what else to say",
"type": "PLAIN_TEXT"
}
}
Which returns:
{
"categories": [
{
"name": "/Science/Computer Science"
},
{
"name": "/Computers & Electronics/Programming"
},
{
"name": "/Jobs & Education"
}
]
}
Direct link to API explorer for interactive testing of my example (change content, filters, etc.)

How to get the poster of a publication?

Actually, i'm getting the post_id of a facebook's post, and i'm searching to get the page who posts it. Does the functions "getParentId" return it?
According to the Facebook API documentation, the parent_id is "the ID of a parent post for this post, if it exists." As such, it's not what you're looking for.
You can get the id of the page to which a post belongs via facebook4j's getFrom method.
Graph explorer example:
postId=5281959998_10151166683754999
GET /v2.9/$postId?fields=from
{
"from": {
"name": "The New York Times",
"id": "5281959998"
},
"id": "5281959998_10151166683754999"
}

Mandrill API with Handlebars "each-loop" not working

Met problem when using Mandrill API to send transactional newsletters. I chose Handlebars for the template parameters. The user name was shown correctly, but data in the list (post titles) were empty. Please help indicate if anything I did wrong. Thank you!
The template is as below, sent to the endpoint /messages/send.json :
func genHTMLTemplate() string {
return "code generated template<br>" +
"Hi {{name}}, <br>" +
"{{#each posts}}<div>" +
"TITLE {{title}}, THIS {{this}}<br>" +
"</div>{{/each}}"
}
The API log in my Settings panel in mandrillapp.com shows the parameters:
{
"key": "xxxxxxxxxx",
"message": {
:
"merge_language": "handlebars",
"global_merge_vars": null,
"merge_vars": [
{
"rcpt": "xxxxxx#gmail.com",
"vars": [
{
"name": "posts",
"content": [
{
"title": "title A"
},
{
"title": "title B"
},
]
},
{
"name": "name",
"content": "John Doe"
}
]
}
],
:
},
:
}
And below is the email received. "title A" and "title B" are expected after "TITLE".
code generated template
Hi John Doe,
TITLE, THIS Array
TITLE, THIS Array
Mandrill decided to create custom handlebars helpers with some horrible, HORRIBLE names:
https://mandrill.zendesk.com/hc/en-us/articles/205582537-Using-Handlebars-for-Dynamic-Content#inline-helpers-available-in-mandrill
title and url will definitely give you grief if your objects happen to have keys named title and urlas well. Why they didn't name their helpers something like toTitleCase and encodeUrl is beyond me.
As far as arrays and #each is concerned, you can work around it by using {{this.title}} instead of {{title}}.
After testing with Mandrill's sample code here I found the key "title" just doesn't work. Dunno the reason (a reserved keyword of Mandrill?) but replace it with "title1", "titleX" or something else it can be rendered correctly.
{
"name": "posts",
"content": [
{
"title": "blah blah" // "title1" or something else works
},
}
while using handlebars as the merge language 'title' is the reserved helpername which is used in handlebars which makes your text in title case. If you do only {{title}} by default it considers as title the empty text. try giving it {{title title}} which should work or changing the key name to something else ( if you dont want your title in title case )
I know this is late but it could be of use to someone trying to debug this issue currently. Take note of this point in the Mandrill documentation
There are two main ways to add dynamic content via merge tags: Handlebars or the Mailchimp merge language. You may already be familiar with the Mailchimp merge language from creating and editing Mailchimp templates. We also offer a custom implementation of Handlebars, which is open source and offers greater flexibility.
To set your merge language, navigate to Sending Defaults and select Mailchimp or Handlebars from the Merge Language drop-down menu.
I've run into a similar issue on Sending Blue, where their default configuration does not enable handle bars so it won't evaluate them.

Resources