Skip to content

Instantly share code, notes, and snippets.

@erikeldridge
Created April 21, 2010 06:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erikeldridge/373487 to your computer and use it in GitHub Desktop.
Save erikeldridge/373487 to your computer and use it in GitHub Desktop.
A YQL utility function in PHP
<?php
function yql( $query )
{
$params = array(
'q' => $query,
'debug' => 'true',
'diagnostics' => 'true',
'format' => 'json',
'callback' => ''
);
$url = 'https://query.yahooapis.com/v1/public/yql?'.http_build_query( $params );
$ch = curl_init( $url );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
$json = curl_exec( $ch );
$response = json_decode( $json );
curl_close( $ch );
return $response;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment