コード例 #1
0
 def test_initialize_invalid_access_token(self):
     with self.assertRaises(ValueError):
         Facebook(
             app_id='123',
             app_secret='123',
             default_access_token=12345,
         )
コード例 #2
0
 def setUp(self):
     super(TestFacebook, self).setUp()
     self.facebook = Facebook(
         app_id='123',
         app_secret='secret',
         default_access_token='my_token',
         default_graph_version='v2.6',
     )
コード例 #3
0
ファイル: cli.py プロジェクト: zetahernandez/fbtool
    def load_config(self):

        if self.app_id and self.app_secret:
            current_app = {
                "app_id": self.app_id,
                "app_secret": self.app_secret
            }
        else:
            current_app = self.load_config_file()

        self.current_app = current_app

        self.facebook = Facebook(
            app_id=self.current_app.get("app_id"),
            app_secret=self.current_app.get("app_secret"),
            default_graph_version="v2.12",
        )
コード例 #4
0
 def test_initialize_required_app_secret_config(self):
     with self.assertRaises(FacebookSDKException):
         Facebook(
             app_id='123',
         )
コード例 #5
0
from facebook_sdk.exceptions import FacebookResponseException
from facebook_sdk.facebook import Facebook

facebook = Facebook(
    app_id='{app_id}',
    app_secret='{app_secret}',
)

facebook.set_default_access_token(access_token='{access_token}')

# Get the name of the logged in user
user_name_request = facebook.request(method='GET',
                                     endpoint='/me?fields=id,name')

# Get user likes
user_likes_request = facebook.request(
    method='GET', endpoint='/me/likes?fields=id,name&limit=1')

# Get user events
user_event_request = facebook.request(
    method='GET', endpoint='/me/events?fields=id,name&limit=2')

message = 'My name is {result=user-profile:$.name}.\n\n' \
          'I like this page: {result=user-likes:$.data.0.name}.\n\n' \
          'My next 2 events are {result=user-events:$.data.*.name}.'

post_to_feed_request = facebook.request(
    method='POST',
    endpoint='/me/feed',
    params={'message': message},
)
コード例 #6
0
from vk import Session, API

from facebook_sdk.exceptions import FacebookResponseException
from facebook_sdk.facebook import Facebook

facebook = Facebook(
    app_id='126705831315228',
    app_secret='1eab07b5da9a647017cef30bfd4cb063',
    default_graph_version='v2.10',
)


def fb_info(id, token):
    facebook.set_default_access_token(access_token=str(token))

    try:
        response = facebook.get(endpoint='/me?fields=id,name,email,picture')
        print(response)
    except FacebookResponseException as e:
        print e
        return None

    json = response.json_body

    name = json.get("name").split(' ')

    json["first_name"] = name[0]
    json["last_name"] = name[1]
    json[
        "image_url"] = "http://graph.facebook.com/" + id + "/picture?type=square"