Giter VIP home page Giter VIP logo

easylasttweet's Introduction

lastTweet

Symfony 2 bundle to add quickly last tweets on your website, you can choose and change the screen name, override template and use your own template, this bundle reqiure dependency on abraham/twitteroauth bundle

Installation

prerequisites

when you install OrwebEasyLastTweetBundle for symfony, this dependency will be add :

https://github.com/abraham/twitteroauth

installation

  1. Add this bundle to your project in composer.json:
{
    "require": {
        "orweb/EasylastTweet": "^1.0",
    }
}
  1. Install with composer
composer.phar require orweb/EasylastTweet 
  1. Register the bundle
<?php
// app/AppKernel.php
public function registerBundles()
{
    $bundles = array(
        // ...
        new \Orweb\EasyLastTweetBundle\OrwebEasyLastTweetBundle(),
    );
    // ...
}

#configuration

##application twitter

first you must create an twitter application on https://apps.twitter.com/ ,and create a token (read permission)

##parameters

you must add your twitter api parameters in app/config/config.yml, the required parameters must be added like this :

# app/config/config.yml
orweb_easy_last_tweet:
    twitter:
        consumer_key: "your_application_key"
        consumer_secret: "your_application_secret_key"
        token: "your_application_token"
        token_secret: "your_application_token_secret"

#Usage

##twig usage:

just add this render command in your twig template (in this example we display the last 3 tweets from the @lyfeor account) :

{% render path('orweb_easy_last_tweet', {screen: 'lyfeor', number: 3}) %}

##controller usage:

if you want to use it in a controller you can get an entity Array with this code:

<?php
// src/controller/someController.php
public function someAction()
{
    $tweets = $this->get('orweb.twitter')->getLastTweets($screen, $number);
    // ...
    
    //if you want retweets and mention 
    $tweets = $this->get('orweb.twitter')->getLastTweets($screen, $number, false, true,true);
}

#Override template

if you want to custom the render (in a twig template usage), you cans specify the path of your override template in the app/config/config.yml :

##config

# app/config/config.yml
orweb_easy_last_tweet:
    twitter:
        consumer_key: "your_application_key"
        consumer_secret: "your_application_secret_key"
        token: "your_application_token"
        token_secret: "your_application_token_secret"
    template:
        path: "path/of/custom/template/tweet.html.twig"

##template

you can use the "tweets" entities Array like this :

{% for tweet in tweets %}
    <dl>
        <dt>{{ tweet.getDate() }}</dt>
        <dd>{{ tweet.getFormatText() | raw }}</dd>
    </dl>
{% endfor %}

to see all the 'tweet' parameters open the Entity/Tweet.php

easylasttweet's People

Contributors

lyfeor 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.