Created
March 31, 2015 09:04
-
-
Save mpmont/305c273f08b1c090e9ed to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Este funciona: | |
$this->data['bsc'] = json_decode(file_get_contents(BAROMETRO_LINK . '/index.php/api/statistics/user/' . $this->data['user']->id)); | |
// Este não funciona: | |
$request = file_get_contents('https://sig.grupoch.pt:4443/ws/ws_server_contacts.php?method=getRadarInfoForUser&user=' . $this->data['user']->sig_id . '&authcode=HjO8mLKrTXxS_2NkX2xshmh!s94NJ5sF'); | |
Este reproduz o seguinte url: https://sig.grupoch.pt:4443/ws/ws_server_contacts.php?method=getRadarInfoForUser&user=158&authcode=HjO8mLKrTXxS_2NkX2xshmh!s94NJ5sF | |
Como pode ver o url funciona. | |
Modifiquei o request externo para usar curl, segue o exemplo: | |
$request = url_get_contents('https://sig.grupoch.pt:4443/ws/ws_server_contacts.php?method=getRadarInfoForUser&user=' . $this->data['user']->sig_id . '&authcode=HjO8mLKrTXxS_2NkX2xshmh!s94NJ5sF'); | |
function url_get_contents($Url) { | |
if (!function_exists('curl_init')){ | |
die('CURL is not installed!'); | |
} | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, $Url); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
$result = curl_exec($ch); | |
curl_close($ch); | |
return $result; | |
} | |
Também não funciona. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment