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.
Related
I have a Windows10 + Python3.7
Right now i using requests for download web content and analyse it. But i can change it to selenium or something else if it needed...
I Want to login to shutterstock website through python to get some information from user pages (my sales data and etc). Shutterstock don't have any API for this actions and for many actions too... I want to write a console script for collecting data only. I will saving data to CSV file
I can parse my page to find all what i'm interested, but before it i'm need to login. And here is a problem because site have a login page with google "I'm not a robot" widget.
I tried to use requests auth functions - but it's doesn't working.
This is a login page:
https://contributor-accounts.shutterstock.com/login
Site don't have any tokens and other auth items. I saw software who connect to shutterstock. It just show popup window with all of this items from login page and then starting work without any windows.
My questions:
How to login to shutterstock?
How to store session for a long time if it possible, because i want to run my script every 4 hours and don't want to see login window every time
Shutterstock is working on building out a contributor api that would allow contributors to programmatically fetch their earnings and downloads data. These specific endpoints are still in progress, plan is to get them out early next year. If you reach out to contributor support they can probably add you as a beta user for these (and other) features that you're looking for.
I am trying to get the data correlated with a user's feed tab on Instagram. Every time I google "get user feed" or anything similar, I am presented with how to get the recent photos that a user has posted.
However, I am trying to get the feed tab, or basically the trending posts of other people that I follow. I tried using Lev Pasha's Instagram API module, but the only related function that I could find was getPopularFeed(), which got posts from the explore page.
I know how to connect to the Instagram API and have done it using the code below, but have not managed to collect the feed tab.
from InstagramAPI import InstagramAPI
InstagramAPI = InstagramAPI("myusername", "mypassword")
InstagramAPI.login()
Update (6/2/2021):
I've decided to add a bit of info here regarding the Instagram API. I'd like to say that this answer is slightly "deprecated" in a sense, as the GitHub repo for this project has been taken down, and therefore it will become harder to develop updates and bug fixes for the module. As a result, I'd actually recommend that you don't use this module, as it will get you banned very quickly from the Instagram platform (the last update was in 2018, and therefore any User-Agent fixes and bot-detection workarounds will not be added).
I'd also like to say that as of now, there seem to be no good modules for the task of Instagram automation. As I've just said, the InstagramAPI module written in my post is long gone, and all the other API projects on Github are also archived / have no more moderation or updates.
TLDR: Maintaining an API which is being updated constantly by a huge corporation is not easy, and therefore you will get banned / blocked easily. I'd recommend using Lev Pasha's or ping's Instagram APIs, although they are both deprecated and might get you blocked quickly. The module in the answer below is also pretty good, although I've noticed that it hasn't been updated in almost 2 years. Also, it's built as a wrapper on top of ping's API.
You can use instapi module to solve your problem. Link to repo
Code example:
from instapi import bind, User
bind('myusername', 'mypassword')
user = User.from_username('some username')
for feed in user.iter_feeds():
# do something with feed
To install instapi using pip:
pip install git+https://github.com/uriyyo/instapi
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).
So basically we would like to integrate our platform with box.net, in particular to be able to stream videos uploaded there, since we can't unfortunately use youtube/vimeo (which support noembed).
I had a look in the doc and:
it seems that for videos the preview is only working for flv and swf.
However I tried with my personal account and one swf embedded with their embedding link didn't preview anyway.
I would like to use the API to upload videos directly from the client, but what happens if the user is not actually authenticated to box.net and the video is private (which is our requirement).
If embedding videos with box is just not going to work we can look at other alternatives, but unfortunately from the list of supported sites http://noembed.com/
it doesn't that we could use any of the services..
For the second point, you can just do all the authentication for your site via box.net. They provide authentication as part of their api: http://developers.box.com/oauth/.
When a user logs into your site, authenticate them with box.net using python requests, and a custom authentication backend, django docs here, example on stack overflow here: Django Remote Authentication without redirecting.
I am making a web application that will monitor the amount of members and discussions in each one of the groups listed here (http://www.codecademy.com/groups#web) and display that information in nice graphs.
However, as you have already seen, it looks like I need to create an account and login with it.
Having in mind that my project is using Python for the server side, how do I do it? Which API is easier? (Google, FB or twitter?)
I would really love if you could also provide some examples because I am really new at this (and at Python too).
The official wrapper around the Twitter API for Python is this one. I used it and it's very easy. You should first read this page and also register an application to get OAuth keys.
Example:
import twitter
# Remember to put these values
api = twitter.Api(consumer_key="",
consumer_secret="",
access_token_key="",
access_token_secret="")
# Get your timeline
print api.GetHomeTimeline()
Hope it helps.