-3

次のコードがあります

class Flickr { 
    private $apiKey = 'YOUR API KEY HERE'; 

    public function __construct() {
    } 

    public function search($query = null) { 
        $search = 'http://flickr.com/services/rest/?method=flickr.photos.search&api_key=' . $this->apiKey . '&text=' . urlencode($query) . '&per_page=50&format=php_serial'; 
        $result = file_get_contents($search); 
        $result = unserialize($result); 
        return $result; 
    } 
}

私の Web ホストでは、file_get_contents の使用が許可されていません。代わりにカールを使用するにはどうすればよいですか?

4

1 に答える 1

0

このようなもの

<?php
    class Flickr { 
    private $apiKey = 'YOUR API KEY HERE'; 

    public function __construct() {
    } 

    public function search($query = null) {
    $url = 'http://flickr.com/services/rest/?method=flickr.photos.search&api_key=' . $this->apiKey . '&text=' . urlencode($query) . '&per_page=50&format=php_serial';
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_URL,$url);
    $result=curl_exec($ch);
    //echo $result;//Your response
    return $result;
    }
  }
于 2013-11-02T08:34:38.557 に答える