How do I get a YouTube video thumbnail from the YouTube API?

Each YouTube video has four generated images. They are predictably formatted as follows: The first one in the list is a full size image and others are thumbnail images. The default thumbnail image (i.e., one of 1.jpg, 2.jpg, 3.jpg) is: For the high quality version of the thumbnail use a URL similar to this: There is also a … Read more

Difference between “as $key => $value” and “as $value” in PHP foreach

Well, the $key => $value in the foreach loop refers to the key-value pairs in associative arrays, where the key serves as the index to determine the value instead of a number like 0,1,2,… In PHP, associative arrays look like this: In the PHP code: $featured is the associative array being looped through, and as … Read more

List of All Locales and Their Short Codes?

The importance of locales is that your environment/os can provide formatting functionality for all installed locales even if you don’t know about them when you write your application. My Windows 7 system has 211 locales installed (listed below), so you wouldn’t likely write any custom code or translation specific to this many locales. Edit: The … Read more

How do I make a redirect in PHP?

Use the header() function to send an HTTP Location header: Contrary to what some think, die() has nothing to do with redirection. Use it only if you want to redirect instead of normal execution. File example.php: Result of three executions: Resuming — obligatory die()/exit() is some urban legend that has nothing to do with actual PHP. It has nothing to do with client “respecting” the Location: header. Sending a header does not … Read more

navigate back with PHP form submission

When you post forms with php, or any other data, you may come back to the page and find a message in the browser like “Document Expired” or “Confirm Form Resubmission With Chrome”. These messages are a safety precaution the browser uses with sensitive data such as post variables. The browser will not automatically give … Read more

Google Calendar API event update always return 404 “not found” error

$service->events->get expects the calendar id and event id as parameters It is important to double-check that both parameters are correct If ‘mygooglecalendarid’ is not your primary calendar, then you are trying to get the event from one calendar and update it into a different one – this will give you a 404 error (bad request). If the eventid is not … Read more