Code Monkey home page Code Monkey logo

aa_app_mod_twitter's Introduction

App-Arena.com App Module: Twitter

Module job

Handles all interactions with the Twitter API. Login, Share, Friend Selector, Send, OpenGraph Posts

Dependencies

  • Nothing

Important functions

  • share - shares information from the model over an popup that calls the twitter API.
    • elem - Botton DOM element
    • share_infos - JSON element with additional share infos (title, desc, short_url)
  • login - start facebook login process
    • scope - FB login scope
    • callback - callback function
  • follow - follow button callback function definition
    • callback - callback function that will be fired after a click on the follow button
  • login - open a popup with login information over the twitter API
  • getUserData - get userdata from twitter after login (automatically called)

Examples

initialize follow button without callback

require(['modules/aa_app_mod_twitter/js/views/TwitterView'], function (Twitter) {
    var twitter = Twitter().init({init: true});
    twitter.libInit();
});

This calls the twitter API to activate the DOM part to change that into a real twitter follow button with fan information.

initialize follow button with callback function

require([
    'modules/aa_app_mod_twitter/js/views/TwitterView'
], function (Twitter) {
    twitter = Twitter().init({init: true});

    twitter.libInit();
    twitter.follow(function (response) {
            that.saveAsFan({
                target: {
                    className: 'fangate_btn_twitter'
                }
            });
        }
    );
});

That will save the current user as fan in the local storage, that the fangate not open again on the next page refresh.

Needed DOM element:

<div class="twitter_fan_btn clearfix">
    <a href="https://twitter.com/<%- _.c('share_twitter_id')%>" class="twitter-follow-button fangate_btn_twitter" data-show-count="true" data-lang="<%- _.t('share_lang') %>">@<%= _.c('share_twitter_id') %><%= _.t('follow') %></a>
</div>

login

require([
    'modules/aa_app_mod_twitter/js/views/TwitterView',
    'modules/aa_app_mod_twitter/js/models/LoginModel'
], function (Twitter, LoginModel) {
    that.twitter = Twitter().init({init: true});
    that.twitterLoginModel = LoginModel().init();
    that.listenTo(that.twitterLoginModel, 'change:logintime', that.twLoginDone);
});

Add the css class .twconnect to your login button. THat activate a click listener to the lofin function.

share button

var that = this;
require([
    'modules/aa_app_mod_twitter/js/views/TwitterView',
	'modules/aa_app_mod_share/js/models/ShareInfosModel'
], function (Twitter, ShareInfoModel) {
	that.shareInfos = ShareInfoModel().init({init: true});
    Twitter().init({init: true}).share($(.twshare), that.shareInfos.attributes);
});

Easier is to call the twShare function from the aa_app_model_share module. To do this, define an element with a twshare class and initialize the module.

App-Manager config values

config default description
tw_consumer_key empty your own twitter API consumer key
tw_consumer_secret empty your own twitter API secret
share_twitter_id empty your twitter account name

App-Manager locale values

locale value example
share_lang de

aa_app_mod_twitter's People

Contributors

mmerchel avatar

Watchers

Sebastian Buckpesch avatar Valentin Klein avatar  avatar James Cloos avatar frd avatar  avatar  avatar Kristijan Risteski avatar  avatar  avatar Marius Brandt avatar  avatar

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.