Category Archives: commlabweb

Foursquare API video

Now playing: How to use the Foursquare API with PHP

Foursquare API tutorial from Robyn Overstreet on Vimeo.

The corresponding code example is in github at
https://github.com/robynitp/commlabweb/blob/master/week5/foursquare_api.php

Correction: at around 12:13 in the video, price I’m looking at the JSON Editor Online and comparing it to my PHP array. I meant to show the exact same JSON text in both, anaemia but I accidentally showed a slightly different version in the online editor — one has a “groups” element and the the other has “venues”. Don’t let that confuse you. The PHP code, with “venues” is right –disregard the one in the JSON editor. If you’re curious to see the correct JSON output, I posted it on gist here.

Cookies! Nom!

In Tuesday’s class, viagra here I talked briefly about cookies, information pills but we didn’t have time to go over them in much detail. As promised, here’s some more information. First, I need to correct a mistake in the example code I demo’ed: Setting a cookie requires the built-in PHP function setcookie() and can’t be done setting the $_COOKIE array directly. This explains why my example code was behaving strangely!

Here’s a short (~4 min) video on how to set and retrieve cookies in PHP:

The video talks about using the PHP time() function to set the expiration date of the cookie. The number used to represent time there is called a Unix timestamp, in case you’re curious.

Remember that you can inspect the cookies that any site has set in your browser by using the Chrome Web Developer tools. Scroll down to the Cookies section of this page for more info.

PHP examples from week 2

The PHP example files from this week’s classes are now available to download as a zip file: Week 2 files.

What you’ll find in there:

  • boxes.php – Dynamically generates rectangular div elements of various sizes. I demo’ed this code in Tuesday’s class
  • tinyfacebook (directory) – From Wednesday’s class, prescription it’s a tiny version of Facebook! If you’re in the Tuesday section, buy information pills make sure you take a look at these.
    • all_people.php – Lists the users and links them to their profile pages.
    • profile.php – The individual profile page. It takes in a user id from the URL and uses $_GET to pull up the right person’s profile.

There is more info about $_GET, and a lot of other things, on my PHP notes page.

Week 1 Miscellany

comic-vlad-how-the-internet-works

A couple of follow-up links from Week 1. If you need help with FTP, decease see this Dreamhost doc about where to find your FTP password (it’s different from the one you use to login to the Dreamhost website) and then for Cyberduck, there’s their help section for more info on how to use it.

I took the HTML examples from both classes, combined them, cleaned them up, and added a bunch of comments into a new HTML example page for your reference. Download it or “View Source” in your browser.

In Wednesday’s class I mentioned the Web Developer Tools that are built into most browsers. I forgot to talk about it Tuesday, so I’ll do a quick demo next time. Each browser’s version is a little different, but they all do basically the same thing: allow you to view and manipulate your HTML and CSS. See the Chrome DevTools documentation for how to use Chrome’s version.