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

SitePoint PHP Blog:
Building a Basic Video Search App with Vimeo’s API and Slim
Nov 24, 2015 @ 12:02:15

The SitePoint PHP blog has a new tutorial posted showing you how to integrate the Vimeo API with Slim to create a simple web application allowing you to search for videos matching a simple query string.

In this tutorial, you’ll get to know the basics of the Vimeo API. With it, you can fetch information on a specific user or get information on the videos uploaded by the user. If the video is private, you can only get it from the API if the user has given permission to your app.

They start with helping you create a new application on the Vimeo developer site and introduce you to the API playground for trying out various API queries and fetching the results. Following this the tutorial starts in on the application itself, helping you get a Slim application up and running with Twig templating and the Vimeo API library. They bootstrap the application with your Vimeo application credentials and how to log into the API via access tokens. The flow then allows the user to connect their Vimeo account to your Slim application. With this connection in place the user can then view their profile information and execute a search on the "videos" endpoint with a simple query string.

tagged: tutorial api vimeo video slim framework search results apiplayground application

Link: http://www.sitepoint.com/building-a-basic-video-search-app-with-vimeos-api-and-slim/

SitePoint PHP Blog:
Suggesting Carbon with Composer – Date and Time the Right Way
Nov 16, 2015 @ 09:16:58

On the SitePoint PHP blog there's a tutorial that's been posted spotlightling a PHP library that can make working with dates and times simpler: Carbon . In this new tutorial they walk you through what the library has to offer and plenty of examples of it in use.

Carbon is a small library for date and time manipulation in PHP. It relies on and extends the core DateTime class, adding helpful methods for a significantly saner experience.

In this article, we’ll take a look at some basic usage examples, and then use it in a real project.

They start with the installation (via Composer) and a few examples of it in use, determining if a given date string is a weekend, in a leap year, etc. They also talk about localization support and working with time intervals. He then gets into the more real-world part of the example, updating the Diffbot client to optionally support Carbon for its date/time handling. He starts with some tests to define how he wants the handling to work and how to use it to parse the date returned from the DiffBot API.

tagged: carbon datetime library tutorial date time diffbot client api

Link: http://www.sitepoint.com/suggesting-carbon-with-composer-date-and-time-the-right-way/

Getting Started with Building APIs in Symfony2
Nov 09, 2015 @ 13:44:28

The IntelligentBee.com site has a "quickstart" kind of tutorial for those wanting to use Symfony 2 to build an API-based application. In this tutorial they walk you through a few step process to create the application and a few actions to get the basics working.

Hello all you Interwebs friends! While we’re passing through the shallow mists of time, REST is becoming more and more of a universal standard when building web applications. That said, here’s a very brief tutorial on how to get started with building APIs in Symfony2.

They make use of two other libraries, the FoSUserBundle, JMSSerializerBundle and Doctrine, to handle some of the low level user management and database functionality. They show you how to:

  • Generate a new bundle
  • Set up API versioning
  • Install the FoSUserBundle and JMSSerializerBundle
  • Configure the application's REST interface
  • Set up the routing to get things to the right place

Code is also included to show the creation of "get user" and "get users" actions along with a simple form and "add user" endpoints to allow new users to register. Wrapping the post up, he includes the code for the other pieces of the CRUD operations, the "edit user" and "delete user" methods.

tagged: api symfony2 tutorial introduction rest user management bundle versioning

Link: http://intelligentbee.com/blog/2015/11/03/getting-started-with-building-apis-in-symfony2/

SitePoint PHP Blog:
How to Build a NASA Photo Gallery with Zend Expressive
Nov 03, 2015 @ 09:52:06

The SitePoint PHP blog has a new tutorial from author Andrew Carter showing you how to create a NASA photo gallery application with the latest framework offering from Zend, Zend Expressive.

In this article, we are going to use Zend Expressive to build a photo gallery using the NASA Astronomy Picture of the Day API. The end result will be the AstroSplash website which was created for the purpose of this article. [...] Zend Expressive is an exciting new micro-framework for building PSR-7 middleware applications. [...] Middleware is a term that will be used a lot in this article. A good definition of middleware is given by the Zend Expressive documentation.

They walk you through the basics of the application and how to set up an account and application over on the NASA API. They help you create the initial project, what the output should look like and commands to remove some extra code. They include the configuration of the container, set up the route middleware, work with the templating for the app and connecting it with Doctrine for database storage. Finally they integrate the NASA API using this library and pull down the latest images from the service.

tagged: zendexpressive tutorial nasa image application api framework middleware

Link: http://www.sitepoint.com/build-nasa-photo-gallery-zend-expressive/

SitePoint PHP Blog:
Powerful Custom Entities with the Diffbot PHP Client
Nov 02, 2015 @ 10:55:18

On the SitePoint PHP blog editor Bruno Skvorc continues his look at the Diffbot service and shows how to use their API to create entities representing objects from the API data.

A while back, we looked at Diffbot, the machine learning AI for processing web pages, as a means to extract SitePoint author portfolios. [...] Since then, the design of the pages we processed has changed, and thus the API no longer reliably works. In this tutorial, apart from rebuilding the API so that it works again, we’ll use the official Diffbot client to build custom entities that correspond to the data we seek (author portfolios).

He starts by setting up the environment for development (a Homestead Improved instance) and pulling in a few libraries to bootstrap the script. He shows the setup and configuration of the Diffbot client, creating a new API application via their UI and using the browser tools to help the service locate the information it needs. He then shows how to extend the client and define an "entity factory" to generate the objects requested. In this case he creates an AuthorFolio class to contain the author's number of posts.

tagged: diffbot client custom entities tutorial author portfolio api

Link: http://www.sitepoint.com/powerful-custom-entities-with-the-diffbot-php-client/

Developer Drive:
How to build an auto-ranking Twitter list with WordPress
Oct 23, 2015 @ 13:55:36

On the Developer Drive site there's a tutorial posted showing how to create a dynamic auto-ranking Twitter list in a WordPress-based application.

My team and I recently built an awesome list template on WordPress that ranks a set of Twitter users based on follower count. It allows a content writer to easily add a list of Twitter handles, and generate a well designed post.

They start with a list of requirements the end result needs to meet including the Twitter information, features it should offer and the resulting output. The rest of the post walks you through every step of the process to get the system set up including:

  • installing the Advanced Custom Fields Pro WordPress plugin
  • Showing an "infinite list" in WordPress
  • Code to loop through the Twitter data
  • using the TwitterAPIExchange PHP library to get Twitter data

All code and steps you'll need to make the system work are included and they've posted a demo so you can see the result first hand.

tagged: autorank wordpress list twitter follower count api interface tutorial

Link: http://www.developerdrive.com/2015/10/how-to-build-an-auto-ranking-twitter-list-with-wordpress/

Hasin Hayder:
Creating a slack bot using PHP to monitor your envato sales
Oct 05, 2015 @ 10:43:03

Hasin Hayder has posted a tutorial to his site showing you how to create a bot for Slack that will monitor your sales on Envato connected via their API.

Slack is awesome. Slack is the de-facto of modern team communication and I am pretty sure that this is not the first time you’re hearing something like this about slack. But if you’re really never used slack, oh boy, I feel pity for you. Anyway, in this article we’re going to make a slack bot that will monitor the sales in our envato account and notify from time to time as soon as someone purchased an item. Pretty useful, eh?

He shows how to make a new channel in your Slack instance (he uses "#sales") and how to add in a named webhook to connect the bot to. He then generates a token on the Envato service to access their API, giving it the needed permissions. He includes the simple curl-based script to make the request to the Envato API to get the latest results and then turn around and post it back to the Slack channel.

tagged: slack bot envato sales api channel automate tutorial

Link: http://hasin.me/2015/10/05/creating-a-slack-bot-using-php-to-monitor-your-envato-sales/

SitePoint PHP Blog:
Conquering Instagram with PHP and the Instagram API
Sep 22, 2015 @ 12:57:21

The SitePoint PHP blog has a tutorial posted that shows you how to "conquer" the Instagram API in your PHP application and integrate it into your application with the help of the Guzzle HTTP client.

Instagram’s API allows us to interact with data such as user info, media (photos and videos), likes, comments, and tags. For example, you can search for media around a specific location and filter the results by time. The API also allows us to post comments or like specific media. For now, only uploading media isn’t supported. You can always look at the API endpoints documentation if you want to know about the full functionality.

They start by talking about the two types of API calls (authenticated/unautheticated) and the limits that are included with each. From there the tutorial shows you how to register a new application, get a new client ID and how to use the API console to test out requests. Next they help you get the [Guzzle]((http://guzzle.readthedocs.org/en/latest/) library installed and connect it to the Instagram API with your client credentials. They integrate this into a simple Slim application using Twig as a templating layer to allow for the OAuth approval process, fetching an access token for the later requests.

With the connection made, they show you how to make requests to do thing like make tag searches, get user feed information (and searches), geographic searches and handling pagination. They also include a link to a PHP Instagram library that can help simplify the process, complete with code examples.

tagged: tutorial instagram api introduction library oauth slim twig

Link: http://www.sitepoint.com/conquering-instagram-with-php-and-the-instagram-api/

Michael Mikowski:
RESTful APIs, the big lie
Sep 09, 2015 @ 11:19:31

Michael Mikowski has a post to his site that suggests that a RESTful API is a big lie and that the concept should "rest in piece" and be replaced with something he calls a "JSON-pure API".

If you have read an internet developer resume or job posting in the past 10 years, then you might be forgiven if you think that RESTful APIs are gifts bestowed from the heavens by The One True Web Developer Deity. RESTful APIs are everywhere. Even the marketing folks are pushing them in sales material intended for CEOs and Human Resources-type folks. So how good of an idea are RESTful APIs really?

He starts with a look at where the concepts for a RESTful API originally came from and defines some of the most common concepts around them (verbs, request/response, etc). He then suggests that they're "pretty awful" and lists some of the larger problems he sees with them:

  • Problem #1: There is little agreement on what a RESTful API is
  • Problem #2: The REST vocabulary is not fully supported
  • Problem #3: The REST vocabulary is not rich enough for APIs
  • Problem #4: RESTful APIs are very hard to debug
  • Problem #5: RESTful APIs are usually tied to HTTP

He suggests that the way to move forward is to migrate to the "JSON-pure API" methodology, fixing most of the problems he listed. He describes this kind of API and how it simplifies the entire process and makes it "more reliable, easier to use, easier to port, and easier to debug."

tagged: restful rest api jsonpure problem lie opinion

Link: http://mmikowski.github.io/the_lie/

SitePoint PHP Blog:
Voice controlled PHP apps with API.ai
Aug 31, 2015 @ 09:36:14

The SitePoint PHP blog has posted a tutorial showing you how to help your applications understand natural language with the help of the Api.ai service.

In this tutorial we’ll be looking into Api.ai, an API that lets us build apps which understand natural language, much like Siri. It can accept either text or speech as input, which it then parses and returns a JSON string that can be interpreted by the code that we write.

They start by explaining some of the concepts you'll need to know in using the service: agents, entities, intents, contexts, aliases and domains (each with a summary and examples). In their example, they show how to get the current time from any given places using their API. He shows you how to set up a free account and create a new agent. He then uses Guzzle (the HTTP client library) to make the request to the API with your API and subscription keys. They show the result of a query for "What's the current time in Barcelona Spain?" and how to extract the "location" value from the results. With this they then search the Google API for the local time of "Barcelona Spain". With the time in hand, they then use the responsive-voice.js library to convert the text to speech at the click of a button.

With all these concepts under your belt, they also walk you through a second application, a currency converter. It uses the same workflow as the previous example with the exception of using the CurrencyLayer.com API to perform the financial conversion. All code needed for this example is included as well. If you'd like to just jump to the end, they've also shared the complete code for both examples over on Github.

tagged: voice control api apiai tutorial localtime currency convert

Link: http://www.sitepoint.com/voice-controlled-php-apps-with-api-ai/