Skip to content

Instantly share code, notes, and snippets.

View gist:242378
<?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 Dec 2, 2009
oauthpanda = programmatic ui exploration + http request + oauth
View example.php
<?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 Apr 21, 2010
A YQL utility function in PHP
View gist:373487
<?php
function yql( $query )
{
$params = array(
'q' => $query,
'debug' => 'true',
'diagnostics' => 'true',
'format' => 'json',
'callback' => ''
@erikeldridge
erikeldridge / SqliteStore.php
Created Apr 21, 2010
a simple key/val store using php & sqlite
View SqliteStore.php
<?php
// a simple key/val store using php & sqlite
// license: http://gist.github.com/375593
class SqliteStore {
function __construct($tableName, $filePath = 'db.sqlite') {
$this->tableName = sqlite_escape_string($tableName);
if (is_numeric($tableName[0])) {
$details = sprintf(
"sqlite will choke on table names that start w/ a number. yours starts w/ '%s'",
View yahoo_bsd_license.txt
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 Apr 23, 2010
A util to do the OAuth dance and make signed requests using the YQL OAuth table
View YqlOauthMonkey.php
<?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 Apr 23, 2010
a restful-ish web api for sqlitestore ( http://gist.github.com/373491 )
View jsonkv.php
<?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 / example.rb
Created Apr 29, 2010
A utility for signing an url using OAuth in a way that's convenient for debugging
View example.rb
require 'oauth_util.rb'
require 'net/http'
o = OauthUtil.new
o.consumer_key = 'examplek9SGJUTUpocjZ5QjBJmQ9WVdrOVVFNHdSR2x1TkhFbWNHbzlNQS0tJnM9Y29uc3VtkZXJzZWNyZXQmeD0yYg--';
o.consumer_secret = 'exampled88d4109c63e778dsadcdd5c1875814977';
url = 'http://query.yahooapis.com/v1/yql?q=select%20*%20from%20social.updates.search%20where%20query%3D%22search%20terms%22&diagnostics=true';
@erikeldridge
erikeldridge / popup.html
Created May 2, 2010
A little yui 3 to launch popup
View popup.html
<!-- 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
A little wrapper for php's mysql handlers
View MysqlUtil.php
<?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" );