Code Monkey home page Code Monkey logo

python-facebook-bot's Introduction

forthebadge forthebadge

Python Facebook Bot

Make your life easier

What is this?


This is a Facebook Bot/Assistant, writen in Python 3 and using Facebook API for some specific tasks.
At the moment, I only implement it some functions to crawl/get Facebook's events by location, since Facebook shutdown that APIs.

What do I need? (requirements.txt)


Right now, I'm only using requests for requesting APIs.

Installation


To install python-facebook-bot, simply:

$ pip install python-facebook-bot

How to use?


First, you need to create a Facebook App for Developer.
Then, run export command for CLIENT_ID and CLIENT_SECRET.
Example:

$ export CLIENT_ID="Your facebook app's ID"
$ export CLIENT_SECRET="Your facebook app's secret key"

Then you can import facebook_bot and use it's methods.
Example with IPython:

Python 3.5.2 (default, Nov 17 2016, 17:05:23)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.0.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import facebook_bot

In [2]: facebook_bot.get_events(1572248819704068)
Out[2]:
{'1572248819704068': {'events': {'data': [{'attending_count': 35,
     'category': 'FAMILY_EVENT',
     'cover': {'id': '1667937513468531',
      'source': 'https://scontent.xx.fbcdn.net/v/t31.0-0/p180x540/12898397_1667937513468531_267697016695005514_o.jpg?oh=1ea3755b790a6837febf9621a3b23f6f&oe=597E6E0D'},
     'declined_count': 0,
     'description': "2020 is just a few years away. Will you join the World for this epic New Years' celebration? I know that you will. I look forward to celebrating with you. \n\nThis is a virtual event and the whole planet is invited.",
     'id': '447828138744610',
     'maybe_count': 119,
     'name': 'Happy New Year 2020',
     'noreply_count': 43,
...........
In [3]:

Where are the tests?


Just run $ python setup.py test
It's may take a while, because we need to scan all available pages.

And here is your Cat

python-facebook-bot's People

Contributors

tudoanh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

python-facebook-bot's Issues

Facebook dev request access

Greetings and kudos for your good work,
My only concern is that during the execution of your code, its requires access to certain features in the facebook API.
My question is which request should I perform to run your code successfully ?
My intuition say it should be the "Page Public Content Access" or "user_tagged_places" or "user_events". Any ideas ?

Events_by_location is pulling in events on incorrect dates

Thank you for the great application. I have found that the location based searches work, except instead if pulling in results for Today, I get results across the board.

For example, I'm looking for Music events in Madison, WI-

TODAY = time.strftime("%Y-%m-%d")
fulllist = facebook_bot.get_events_by_location(43.0730517, -89.4012302, place_type='*',
                           distance=1000, scan_radius=500, base_time=TODAY,
                           fields=EVENT_FIELDS, f=None)

for line in fulllist:
    try:
        if line[0]['category'] == 'EVENT_MUSIC':
            try:
                eventname = line[0]['name']
                eventid = line[0]['id']
                eventstart = line[0]['start_time']
                eventlocation = line[0]['place']['location']['street']
                eventid = {'name':eventname, 'starttime': eventstart, 'location': eventlocation}
                if eventid not in dicts:
                    dicts.append(eventid)
            except:
                print('uhhm')
    except:
        continue

for i in dicts:
    print(i)

My results are as follows. Notice I get ZERO results for today, but instead results for dates across the board.

{'name': 'Le Vent Du Nord', 'location': '800 Langdon St', 'starttime': **'2018-05-05**T20:00:00-0500'}
{'name': "University Opera's La Boheme", 'location': '800 Langdon St', 'starttime': **'2018-02-23**T19:30:00-0600'}
{'name': 'Jack and Kitty: Vaudeville Jug Band Folk', 'location': '201 State St', 'starttime': '**2018-08-07**T19:00:00-0500'}
{'name': 'Propaganda Concert', 'location': '365 E Campus Mall, Ste 200', 'starttime': '2018-03-03T19:00:00-0600'}
{'name': 'Dirty Walter & The Fellas LIVE at SconnieBar', 'location': '1421 Regent Street', 'starttime': '2018-02-17T21:00:00-0600'}
{'name': 'Madtown Undergound Summer Kickoff!', 'location': '1206 Regent Street', 'starttime': '2018-06-02T19:00:00-0500'}
{'name': 'The Lacs - Dirt Rock Tour - The Annex, Madison, WI', 'location': '1206 Regent Street', 'starttime': '2018-04-15T18:00:00-0500'}

Thank you,
Nate

Great package

Would love to be able to install this package through pip. It would be useful to look at the pip documentation to get this package to do something like:

import getfbevents

c = getfbevents.losangeles(2017/04/18-2017/05/2018)

print(c)

fbevent, location, address, date

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.