no tengo mucha experiencia en PHP y estoy integrando un servicio web (dribbble.com) en una página. El caso es que en local me funciona perfectamente, pero cuando lo subo al server encuentro que tiene un problema con la directiva fopen. Concretamente el "famoso" error es el siguiente:
Código PHP:
Warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration in /homepages/27/d229005224/htdocs/test-mobile/mock-hd-f3-test/php/src/base.php on line 32
Warning: file_get_contents(http://api.dribbble.com//players/simplebits) [function.file-get-contents]: failed to open stream: no suitable wrapper could be found in /homepages/27/d229005224/htdocs/test-mobile/mock-hd-f3-test/php/src/base.php on line 32
Warning: Invalid argument supplied for foreach() in /homepages/27/d229005224/htdocs/test-mobile/mock-hd-f3-test/php/src/base.php on line 33
Warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration in /homepages/27/d229005224/htdocs/test-mobile/mock-hd-f3-test/php/src/base.php on line 32
Warning: file_get_contents(http://api.dribbble.com//players//draftees?page=1&per_page=3) [function.file-get-contents]: failed to open stream: no suitable wrapper could be found in /homepages/27/d229005224/htdocs/test-mobile/mock-hd-f3-test/php/src/base.php on line 32
Warning: Invalid argument supplied for foreach() in /homepages/27/d229005224/htdocs/test-mobile/mock-hd-f3-test/php/src/base.php on line 33
Notice: Undefined property: Player::$players in /homepages/27/d229005224/htdocs/test-mobile/mock-hd-f3-test/php/src/player.php on line 79
Warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration in /homepages/27/d229005224/htdocs/test-mobile/mock-hd-f3-test/php/src/base.php on line 32
Warning: file_get_contents(http://api.dribbble.com//players//following?page=1&per_page=10) [function.file-get-contents]: failed to open stream: no suitable wrapper could be found in /homepages/27/d229005224/htdocs/test-mobile/mock-hd-f3-test/php/src/base.php on line 32
Warning: Invalid argument supplied for foreach() in /homepages/27/d229005224/htdocs/test-mobile/mock-hd-f3-test/php/src/base.php on line 33
Notice: Undefined property: Player::$players in /homepages/27/d229005224/htdocs/test-mobile/mock-hd-f3-test/php/src/player.php on line 69
Warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration in /homepages/27/d229005224/htdocs/test-mobile/mock-hd-f3-test/php/src/base.php on line 32
Warning: file_get_contents(http://api.dribbble.com//players//shots?page=1&per_page=4) [function.file-get-contents]: failed to open stream: no suitable wrapper could be found in /homepages/27/d229005224/htdocs/test-mobile/mock-hd-f3-test/php/src/base.php on line 32
Warning: Invalid argument supplied for foreach() in /homepages/27/d229005224/htdocs/test-mobile/mock-hd-f3-test/php/src/base.php on line 33
Notice: Undefined property: Player::$shots in /homepages/27/d229005224/htdocs/test-mobile/mock-hd-f3-test/php/src/player.php on line 49
Código PHP:
<?php
if (preg_match("/base\.php$/", $_SERVER['PHP_SELF'])){
exit('No direct script access allowed');
}
/**
* Dribbble base API class
*
* @author Martin Bean <[email protected]>
**/
class Base
{
/**
* Dribbble API base URL
*
* @var string
**/
var $baseUrl = "http://api.dribbble.com/";
/**
* undocumented function
*
* @return void
**/
public function get($url, $options=array())
{
$url = $this->baseUrl . $url;
if (!empty($options)) {
$url.= "?" . http_build_query($options);
}
$result = json_decode(file_get_contents($url));
foreach ($result as $key => $value) {
$this->{$key} = $value;
}
return $this;
}
/**
* undocumented function
*
* @param string $url
* @param array $options
* @return string
**/
public function paginated_list($object)
{
return $object;
}
}
Muchas gracias!
NOTA: He probado crear un archivo php.ini en cada una de las carpetas donde tengo archivos php como me indicaron desde mi hosting, pero no he conseguido que funcione. Podríais decirme si es correcto esto? Usar el flag de fopen en on ahí. De ser así, podríais poner un ejemplo concreto de su sintaxis, por si fuera que no creara bien el archivo?