Giter Club home page Giter Club logo

dynacover's Introduction

dynacover

A PHP GD + TwitterOAuth demo to dynamically generate Twitter header images and upload them via the API. This enables you to build cool little tricks, like showing your latest followers or sponsors, latest content creted, a qrcode to something, a progress bar for some goal, and whathever you can think of.

The demo is explained in detail in this guide: How to Dynamically Update Twitter Cover Image to Show Latest Followers Using PHP GD and TwitterOAuth.

Requirements

  • PHP (cli only) 7.4+
  • GD / PHP-GD
  • Curl
  • Composer

You also need to register an application within the Twitter Developers Portal and obtain 4 tokens:

  • Consumer / App Token
  • Consumer / App Secret
  • User / Access Token
  • User / Access Token Secret

Installation

  1. Clone this repository

Start by cloning this repository to your local PHP dev environment or remote PHP server:

git clone https://github.com/erikaheidi/dynacover.git
cd dynacover
  1. Install Composer Dependencies
composer install
  1. Set Up Twitter Credentials

Create a file named credentials.php in the root folder containing your keys as follows:

#credentials.php
<?php

return [
    'twitter_consumer_key' => 'APP_CONSUMER_KEY',
    'twitter_consumer_secret' => 'APP_CONSUMER_SECRET',
    'twitter_user_token' => 'USER_ACCESS_TOKEN',
    'twitter_token_secret' => 'USER_ACCESS_TOKEN_SECRET',
];

Replace the keys accordingly and save the file.

  1. Test Twitter Connection

To test that your credentials are valid, you can list your latest followers with:

php dynacover fetch followers

If everything is set up correctly, you will see a list with your 10 latest followers.

  1. Preview your Cover

To preview your cover without uploading it to Twitter, run:

php dynacover cover generate

Covers are generated in the root of the application folder, with the name latest_header.png. Check the generated image before uploading it to Twitter to confirm it has your latest followers and it looks like you expect.

  1. Upload to Twitter

To generate and update your cover, run:

php dynacover cover update
  1. Set Up Crontab (Optional)

For this to be completely dynamic and update frequently, you'll need to include the script to your Crontab or equivalent.

To open the current user's crontab, run:

crontab -e

This will open up a text editor. You should include the full paths to both the php executable and the dynacover script, like in this example which will update the cover every 5 minutes:

*/5 * * * * /usr/bin/php /home/erika/dynacover/dynacover cover update > /dev/null 2>&1

dynacover's People

Contributors

erikaheidi avatar

Stargazers

 avatar

Watchers

 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.