Sharepoint 2013 - create a reply to discussion using python - python

We have a discussion board in Sharepoint 2013, which has a workflow associated to perform several updates and send notifications to persons defined in the parent topic. The workflow runs when a reply is created.
We need to create automated replies to topics in that discussion board from a python microservice (running in kubernetes), and be sure the workflow is started correctly, in the same way when manual replies are created.
We have tried several things without success:
Using REST API from python. We can create the reply but the ParentItemID field it's not being assigned correctly, so it's not showing as a reply of the parent topic and the workflow is not running with the info of the parent
Using JSOM (JavaScript Object Model): we created a web page in the sharepoint site that can create the reply correctly using a content web part with a JS code, but we have not found a way to run this page from the python script. As it has JS, the option is to use requests-html library, which uses pyppeteer, but it requires to install Chrome and we don't have the option to install all prerequisites for this. Is there any other way to use the JSOM API from python?
We will really appreciate any help on this. Thanks!

Related

Retrieving Facebook Page comments with python script

I am building a python script that is trying to stream a screen capture to my Facebook Page and to be able to retrieve all the comments from the Facebook Live stream real time so that I can do some processing in the middle of the stream.
The Facebook App was set up (in development mode) but when I tried to retrieve the comments from my live stream, I am only able to retrieve comments with their name and id ("from") that are made as the Facebook Page Admin, not comments that are made by other users. I need the user's id, user's name and their comments.
I understand that I need to get Facebook App to be live mode in order to retrieve all the comments with their details tagged to it. When I tried to get it, it tells me that I need to get the permission approved. I tried to fill in most of the stuff and try to get the two permission (manage_page for the comments and live video API for the streaming) but I was unable to because I left the platform empty.
Below is the message I got:
You do not have any platforms eligible for review. Please configure a platform on your Settings page.
The problem is when I tried to choose a platform that was shown in the list, python script does not fall in the list of platform.
Does anyone know of a solution or a different way to achieve what I need to retrieve?
Have you tried using PyLivestream?
It can be used to stream to Facebook Live using FFmpeg (to multiple services simultaneously actually, like Periscope, YouTube etc).
It adheres to the RTMPS requirement and should be an option for you if I interpret your needs correctly.
python -m pip install PyLivestream
Facebook Live
Facebook Live requires FFmpeg >= 4.2 due to mandatory RTMPS
configure your Facebook Live stream
Put stream ID from https://www.facebook.com/live/create into the file facebook.key
Run Python script for Facebook with chosen input
Check out the PyPi PyLivestream page for details.
To be able to retrieve all the comments from the Facebook Live stream
I'm not sure if this is possible using PyLivestream alone, but the Polls API can be used to represent VideoPoll objects in the Graph API, to create polls on live video broadcasts and get real-time responses from your viewers and can be created with the
POST /{live-video-id}/polls
endpoint on a LiveVideo object.
Upon creation, the API will return a VideoPoll object ID, which you can use to manipulate the poll and query for viewer interactions.
Guess you'll have to do a bit of digging to figure out the details,
but I believe this would be the right way to approach this task.
In order to get the "from" field when retrieving the comments, you need to have manage_pages permission from your Facebook App that is linked to your Facebook Page. You will need to submit an App review for your Facebook App that usually takes 1-3 days to process. If you are lucky, it will probably take about 6-8 hours.
Once it is approved, you can request the permission and get your application to go live.
Also use the Page Access token in your "access_token" field when invoking the API so that it will allow you to pull the "from" field, which contains the id and name of the user.

How do I send myself a message on Facebook using python?

It appears pyfacebook and simplefacebook are deprecated. So is the facebook e-mail service. What is the current way of accomplishing this?
https://developers.facebook.com/products/messenger/
There appears to be links to build apps integrating messenger support here.
You can try to utilize the APIs there, since several apps seem integrated using it, I assume it is unlikely to change drastically anytime soon.
Here is a link I found which demonstrates the API for how to send messages using facebook's send API https://developers.facebook.com/docs/sharing/reference/send-dialog The tutorial is for Javascript but you might be able to adapt it to work for Python as well.
Here's the build for an app called Facebook Autoresponder, you might be able to reverse engineer their process from looking at it : http://sourceforge.net/projects/facebook-autoresponder/files/?source=navbar

publish on facebook page from python cron job

I have a Facebook page dedicated to a web site with some statistical information and I want to publish some daily news on that page, like "today A equals to X and B is greater than Y, etc". What I want to publish is irrelevant anyway.
The problem is that I want this activity to be fully automated. I mean I do not want to click somewhere, I want this to be done from cron job. Solutions I found all depend on some per posting login related user activity.
Also, it is not quite clear to me if this is against FB policy.
So, the question is, how can I publish to Facebook page as Facebook page (not as myself) from cron job fully unattended.
My web-site is written in Django/Python3 and I know Python more or less, at least I know Python much better than PHP, so Python based solutions are preferred, but any are welcome of cource.
You can create facebook posts using the Graph-API when you have a page access token with the publish_actions permission. Take a look at the 'Publishing' heading in the page feed api documentation.
The easiest way to execute a django script periodically, is to create a custom management command and run it as a cron-job in linux or a scheduled task in windows. In this script you'll want to generate the message you want to post. Then you can do a POST request to graph.facebook.com/{page-id}/feed/ to post the message to the page's feed. This can be done using e.g. urllib2. The exact parameters and formats expected by the API can be found in the documentation (again under the 'Publishing' heading).

Use Facebook Graph API with Django

I am doing a test project that uses Facebook Graph API to retrieve data from an events page. I need to use the following url: https://graph.facebook.com/OffTheGridSF/events and do a HTTP GET from my web app. I created a facebook app (for testing) and have the APP_ID, APP_SECRET. I was wondering which library (if any) should I use. I have looked at django-facebook and pyfb. I am not sure how the authentication process works. I don't need a login page for my website. I only need the JSON containing the list of events. Any help as to how I should proceed will be highly appreciated. I just started playing around with Django a few hours ago so nothing is trivial.
You can try using python requests library directly with the URL you want to GET. Checkout requests-oathlib

How to programmatically create a new Page in MoinMoin?

I want to write a python script that calls some external REST service and then creates MoinMoin pages based on the data that I pull back. I am using Python 2.4.3 on CentOS 5.3 and MoinMoin 1.9.3 in a wiki farm configuration.
Note I don't want to embed data in pages using Macros, as I already know how to do that. I want to create a Page from a Template if at all possible without the user having to do anything.
Can anyone post some example code, or links to example code, on how to go about programmatically creating a Page in MoinMoin?
Here is a documentation of the MoinMoin API: http://moinmo.in/MoinAPI/Beispiele
It is in german (the main MoinMoin developers are german).
I think what you want is the PageEditor: http://moinmo.in/MoinAPI/Beispiele#PageEditor

Categories