Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

SitePoint PHP Blog:
3 Ways to Implement Embeddable Custom Badges
Dec 29, 2014 @ 15:12:38

The SitePoint PHP blog has a recent tutorial showing you how you can use one of three different ways to embed badges into your site. These "badges" are a common practice among sites allowing other sites/applications to embed small statistics such as number of Tweets or Likes about a page.

One great way of organically promoting your application is to provide “badges”; snippets of content that people can embed on their own websites. [...] This can contain up-to-the-minute information from your application about a user, piece of content or another object, dynamically generated and inserted into other websites. In this article I’m going to take a look at some of the ways you can implement this.

He walks you through the creation of a simple application based on Silex, using Twig for template rendering and the WideImage library for creating the images. His datastore, a static array, lists an image, rank and number of "trophies" for each user of the system. He creates a main page showing all of the badges at once, making use of an "iframe" to contain the dynamically created image. He shows how to use the WideImage library to pull in the background, avatar and trophy images, merge them together and add a bit of text with the username and level ranking. Finally he includes the Javascript needed so the remote site can just use a "script" tag to pull in the rendered image and place it on their page.

tagged: tutorial badge embed javascript iframe silex twig wideimage

Link: http://www.sitepoint.com/3-ways-implement-embeddable-custom-badges/

DevShed:
Caching Dynamic Twitter Signature Images with PHP
Sep 02, 2009 @ 13:26:59

DevShed finishes off their series looking at creating the Twitter "badges" for your site, complete with latest post and profile pic, in this fifth and final part. This time they focus on caching the results.

You may find that Twitter will start cutting off your requests. At first that may seem confusing, but keep in mind that regardless of where the image actually appears, the request always originates from the IP address of the web server where the script is located. To circumvent this pitfall, we can add a caching feature to our Twitter signature image application.

Their caching method involves two steps: saving the user information including the latest tweet and making a local copy of the profile pic (avatar). The details are cached into a local file with the XML returned from the feed request.

tagged: tutorial twitter badge dynamic

Link:


Trending Topics: