Skip to content

Instantly share code, notes, and snippets.

@ydn
ydn / gist:242381
Created November 25, 2009 00:52
YML, YQL, PHP, CSS, and HTML for YAP app search box referenced in YDN blog post: http://developer.yahoo.net/blog/archives/2009/11/yahoo_app_searchbox.html
<?php
$search_term = $_GET['search_term'];
if($search_term){
//http://developer.yahoo.com/yql/console/?q=select%20*%20from%20search.web%20where%20query%3D%22pizza%22
$yql_search_url = "http://query.yahooapis.com/v1/public/yql?"
."q=select%20*%20from%20search.web%20where%20query%3D%22$search_term%22&"
."format=json&diagnostics=false&callback=";
@ydn
ydn / gist:281448
Created January 19, 2010 23:56
sample code for creating a tabset in YAP
<?php // YAP sample code: YML tabset
//note: http://gist.github.com/327012 provides alternate example
/*
Normally, this wouldn't all be in the same file, but for the sake of simplicity we do so here.
Once the app is loaded, clicking on the tabs calls back to the server-side code and regenerates
the app, including a secondary call for content.
Usage:
@ydn
ydn / gist:284358
Created January 23, 2010 01:18
publish an update w/ image to Yahoo! using the PHP SDK
<?php
/*
Purpose:
This script creates an oauth access token for you, and then
allows you to use that token to publish an update (that
includes a thumbnail picture) w/ the Yahoo! Updates API
Prerequisites
* A server with PHP 5
@ydn
ydn / gist:318916
Created March 1, 2010 23:07
YML-based auto-rotating carousel for YAP
<?php // YML-based auto-rotating carousel for YAP
/*
Overview:
- This code displays a series of images and automatically rotates through them using yml
- This code was presented as part of a post on the YDN blog: http://developer.yahoo.net/blog/archives/2010/03/yap_sample_code_image_carousel_w_autorotation.html
Usage:
1. Put this file on your server
2. Create a YAP app and set the "Application URL" to the url of this file, eg http://example.com/rotator.php
@ydn
ydn / gist:320156
Created March 3, 2010 00:28
Fetch Twitter search results using YQL + JSONP + a simple JavaScript handler function
<!-- Fetch Twitter search results using YQL + JSONP + a simple JavaScript handler function -->
<!-- Described in blog post: http://developer.yahoo.net/blog/archives/2010/03/yql_code_samples_yql_is_easy_to_use.html -->
<ul>Puppy Tweets:</ul>
<script>
function handleResponse (json) {
var results = json.query.results.json.results,
ul = document.getElementsByTagName( 'ul' )[0],
li = null;
for ( var i = 0; i < results.length; i++ ) {
@ydn
ydn / gist:320161
Created March 3, 2010 00:32
Scrape content off the World Wildlife Fund's site and pass it back to a jQuery handler
<!-- Scrape content off the World Wildlife Fund's site and pass it back to a jQuery handler -->
<!-- Introduced in YDN blog post: http://developer.yahoo.net/blog/archives/2010/03/yql_code_samples_yql_is_easy_to_use.html -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script>
function cbfunc(json){
$.each( json.query.results.h4, function ( i, h4 ) {
var div = $( '<div/>' ).text( h4.content );
$.each( json.query.results.ul[i].li, function ( j, li ) {
@ydn
ydn / gist:320165
Created March 3, 2010 00:34
Use YQL to convert XML to JSON in your sleep
<!-- Use YQL to convert XML to JSON in your sleep -->
<!-- Introduced in YDN blog post: http://developer.yahoo.net/blog/archives/2010/03/yql_code_samples_yql_is_easy_to_use.html -->
<script src="http://yui.yahooapis.com/3.0.0/build/yui/yui-min.js"></script>
<ul>UN Headlines:</ul>
<script>
var Y = new YUI();
function handleResponse ( json ) {
var items = json.query.results.item;
for ( var i = 0; i < items.length; i++ ) {
@ydn
ydn / code.php
Created March 9, 2010 19:44
Tabbed navigation for YAP small view
<?php // Tabbed navigation for YAP small view
// See usage and license details in http://gist.github.com/327012/#file_readme.txt
?>
<? if('1' == $_GET['item']): ?>
this is item 1 content
<? elseif('2' == $_GET['item']): ?>
this is item 2 content
<? elseif('3' == $_GET['item']): ?>
@ydn
ydn / index.php
Created March 12, 2010 18:41
Sample YAP code for consistent font formatting between small and large views
<!-- Sample YAP code for consistent font formatting between small and large views -->
<!-- Usage and licensing info in http://gist.github.com/330606#file_readme.txt -->
<style>
#wrapper {
font-family: sans-serif;
font-size: 16pt;
}
</style>
<div id="wrapper">
@ydn
ydn / gist:352518
Created April 1, 2010 23:32
sample code for making an oauth request using YAP OAuth credentials
<?php // sample code for making an oauth request using YAP OAuth credentials
// http://oauth.googlecode.com/svn/code/php/OAuth.php
require 'OAuth.php';
// get key/secret from your app dashboard http://developer.apps.yahoo.com/projects
$key="exampleGWklXQ3FTSk1iJmQ9WVdrOVYyOVlhMjR4TnpnbWNHbzlNQS0tJnM9Y29uc3VtZXJzZWNyZXQmeD0yNQ--";
$secret="examplec1a002564a746354ff159380b9d689";
$consumer = new OAuthConsumer($key, $secret);