Skip to content

Instantly share code, notes, and snippets.

<?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=";
@erikeldridge
erikeldridge / example.php
Created December 2, 2009 05:44
oauthpanda = programmatic ui exploration + http request + oauth
<?php
error_reporting(E_ALL);
require 'private.php';
require 'gistfile1.php';
$foo = new Foo(array(
'request_client' => new YahooCurlWrapper,
'oauth_client' => new StandardOauthClient,
@erikeldridge
erikeldridge / gist:373487
Created April 21, 2010 06:11
A YQL utility function in PHP
<?php
function yql( $query )
{
$params = array(
'q' => $query,
'debug' => 'true',
'diagnostics' => 'true',
'format' => 'json',
'callback' => ''
@erikeldridge
erikeldridge / yahoo_bsd_license.txt
Created April 22, 2010 18:11
Yahoo! BSD License
Software License Agreement (BSD License) Copyright (c) 2009, Yahoo! Inc. All rights reserved.
Redistribution and use of this software in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- Neither the name of Yahoo! Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission of Yahoo! Inc.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
@erikeldridge
erikeldridge / YqlOauthMonkey.php
Created April 23, 2010 03:20
A util to do the OAuth dance and make signed requests using the YQL OAuth table
<?php
// A util to do the OAuth dance and make signed requests using the YQL OAuth table (github.com/yql/yql-tables/raw/master/oauth/oauth.xml)
// usage: create an object above wherever you'll need to make a request, if the user doesn't have an token, it'll do the dance to get one, and store it in a cookie
// example: see the example.php file below
// license: http://gist.github.com/375593
class YqlOauthMonkey {
function __construct ( $params ) {
@erikeldridge
erikeldridge / jsonkv.php
Created April 23, 2010 07:59
a restful-ish web api for sqlitestore ( http://gist.github.com/373491 )
<?php
// a web api for sqlitestore ( http://gist.github.com/373491 )
// usage: GET retrieves data, POST inserts. Value to insert is validated as json before writing to store.
// example: http://github.com/erikeldridge/openid-oauth-yql-yui-party/blob/master/start.xml
// license: http://gist.github.com/375593
require 'SqliteStore.php';
$filters = array(
@erikeldridge
erikeldridge / popup.html
Created May 2, 2010 01:42
A little yui 3 to launch popup
<!-- A little yui 3 to launch popup
Usage:
1. mix this in w/ your html
2. click the "click" link
3. observe popup
License: Yahoo! BSD http://gist.github.com/375593
-->
@erikeldridge
erikeldridge / MysqlUtil.php
Created May 2, 2010 10:44
A little wrapper for php's mysql handlers
<?php /* A little wrapper for php's mysql handlers
Usage:
1) Drop this code on a page
2) Create a table as you like
3) Initialize an object like this: $db = new MysqlUtil( $db_host, $db_name, $db_user, $db_pass );
4) Run queries like this:
$db->query( "select * from `my_table` where `field_name`='value';" );
5) Escape input using sprintf notation & logic like this:
$db->query( "insert into `my_table` ( `field1` ) values ( '%s' )", "my ' value" );
<?php
require_once("../yosdk/yahoo-yos-social-php5-86eef28/lib/OAuth/OAuth.php");
$consumer = new OAuthConsumer($_GET['cKeyInputField'], $_GET['cSecretInputField']);
$api_endpoint = 'http://test.erikeldridge.com/hak/cck.php';
$params = array('pAppid' => $_REQUEST['pAppid']);
$params = array('name' => $_REQUEST['name']);
$params = array('description' => $_REQUEST['description']);
@erikeldridge
erikeldridge / yql_util.rb
Created May 14, 2010 07:33
A convenience function for making a call to YQL from Ruby
# This is a convenience function for making a call to YQL from Ruby
# License: Yahoo! BSD http://gist.github.com/375593
# Usage: http://erikeldridge.wordpress.com/2010/02/18/ruby-yql-utility-function-example/
require 'net/http'
require 'rubygems'
require 'json'
def yql(query)
uri = "http://query.yahooapis.com/v1/public/yql"