Plugin Directory

Changeset 533328


Ignore:
Timestamp:
04/19/2012 08:50:17 AM (14 years ago)
Author:
slowmove
Message:

Uses file_get_contents() if curl is not installed

Location:
spotify-embed-creator/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • spotify-embed-creator/trunk/Api/Spotify-Request-handler.php

    r531922 r533328  
    1010        if ( isset($searchtype) && isset($searchquery) )
    1111        {
    12             $response_list = array();
    1312            // get the response
    14             $url = "http://ws.spotify.com/search/1/".$searchtype.".json?q=".$searchquery;           
    15             $curl;
    16             $curl = curl_init();
    17      
    18             curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 2);
    19             curl_setopt($curl, CURLOPT_HEADER, false);
    20             curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
    21             curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    22             curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
    23             curl_setopt($curl, CURLOPT_URL, $url);
    24      
    25             $response = json_decode(curl_exec($curl));
    26             curl_close($curl); 
     13            $url = "http://ws.spotify.com/search/1/".$searchtype.".json?q=".$searchquery;               
     14            if( function_exists('curl_version') == "Enabled" )
     15            {
     16                $curl;
     17                $curl = curl_init();
     18         
     19                curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 2);
     20                curl_setopt($curl, CURLOPT_HEADER, false);
     21                curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
     22                curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
     23                curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
     24                curl_setopt($curl, CURLOPT_URL, $url);
     25         
     26                $response = json_decode(curl_exec($curl));
     27                curl_close($curl); 
     28            }else{
     29                $res = file_get_contents($url);
     30                $response = json_decode($res);
     31            }
    2732            // write it as json
    2833            header('Cache-Control: no-cache, must-revalidate');
     
    4146        $response = array('error' => true, 'message' => 'please login');
    4247        header('HTTP/1.1 500 Internal Server Error');
    43     }
     48    }   
    4449   
    45     echo json_encode($response);
     50    echo json_encode($response);   
    4651?>
  • spotify-embed-creator/trunk/Readme.txt

    r533079 r533328  
    44Requires at least: 3.0
    55Tested up to: 3.3
    6 Stable tag: 1.0.2
     6Stable tag: 1.0.3
    77
    88Search for Album or Track on Spotify and create a Spotify Play Button.
     
    3535== Changelog ==
    3636
     37= 1.0.3 =
     38* Uses file_get_contents() if curl isn't installed
     39
    3740= 1.0.2 =
    3841* Changed name on the shortcode function due to incompatibility with another plugin
  • spotify-embed-creator/trunk/Spotify-Embed-Creator.php

    r533266 r533328  
    55  Plugin URI: http://slowmove.se/wordpress-plugin-spotify-embed-creator/
    66  Description: Search for Album or Song on Spotify and create a Spotify Play Button
    7   Version: 1.0.2
     7  Version: 1.0.3
    88  Author: Erik Johansson
    99  Author URI: http://slowmove.se
Note: See TracChangeset for help on using the changeset viewer.