Пример #1
0
    def post(self, request):
        friends_ids = request.data.get('friends_ids')
        message = request.data.get('message', u'')
        graph = FacebookAuth(request.user.id).get_graph()

        message_text = u' - '.join([message, settings.INVITE_MESSAGE])
        try:
            graph.put_object(
                parent_object='me', connection_name='feed',
                message=str(message_text),
                tags=friends_ids)
        except Exception, e:
            return Response({'message': e.message},
                            status=status.HTTP_400_BAD_REQUEST)
Пример #2
0
    def get(self, request, format=None):
        """
        Return a list of all users.
        """
        try:
            if not request.user.is_authenticated():
                raise NotValidFacebookAccount("User needs to be authenticated")
            graph = FacebookAuth(request.user.id).get_graph()
            users = graph.get_connections(
                id='me', connection_name='friends', fields='name')
            data = users.get('data')
        except NotValidFacebookAccount:
            data = []

        return Response(data)
Пример #3
0
    def get(self, request, format=None):
        """
        Return a list of all users.
        """

        after = request.GET.get('after', None)
        try:
            if not request.user.is_authenticated():
                raise NotValidFacebookAccount("User needs to be authenticated")
            graph = FacebookAuth(request.user.id).get_graph()
            users = graph.get_connections(
                id='me', connection_name='taggable_friends',
                fields='name,picture', limit='30', after=after)
            data = users
        except NotValidFacebookAccount:
            data = []

        return Response(data)