function flickrsync_log($msg) { flickrsync_log_mesmo($msg); flickrsync_vardump($_SESSION); flickrsync_vardump($_GET); }
function post($data, $type = null) { if (is_null($type)) { $url = $this->rest_endpoint; } if (!is_null($this->custom_post)) { return call_user_func($this->custom_post, $url, $data); } if (!preg_match("|https://(.*?)(/.*)|", $url, $matches)) { die('There was some problem figuring out your endpoint'); } if (function_exists('curl_init')) { // Has curl. Use it! $curl = curl_init($this->rest_endpoint); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, $data); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($curl); curl_close($curl); } else { // Use sockets. foreach ($data as $key => $value) { $data[$key] = $key . '=' . urlencode($value); } $data = implode('&', $data); $fp = @pfsockopen('ssl://' . $matches[1], 443); if (!$fp) { die('Could not connect to the web service'); } fputs($fp, 'POST ' . $matches[2] . " HTTP/1.1\n"); fputs($fp, 'Host: ' . $matches[1] . "\n"); fputs($fp, "Content-type: application/x-www-form-urlencoded\n"); fputs($fp, "Content-length: " . strlen($data) . "\n"); fputs($fp, "Connection: close\r\n\r\n"); fputs($fp, $data . "\n\n"); flickrsync_vardump($data); $response = ""; while (!feof($fp)) { $response .= fgets($fp, 1024); } fclose($fp); $chunked = false; $http_status = trim(substr($response, 0, strpos($response, "\n"))); if ($http_status != 'HTTP/1.1 200 OK') { die('The web service endpoint returned a "' . $http_status . '" response'); } if (strpos($response, 'Transfer-Encoding: chunked') !== false) { $temp = trim(strstr($response, "\r\n\r\n")); $response = ''; $length = trim(substr($temp, 0, strpos($temp, "\r"))); while (trim($temp) != "0" && ($length = trim(substr($temp, 0, strpos($temp, "\r")))) != "0") { $response .= trim(substr($temp, strlen($length) + 2, hexdec($length))); $temp = trim(substr($temp, strlen($length) + 2 + hexdec($length))); } } elseif (strpos($response, 'HTTP/1.1 200 OK') !== false) { $response = trim(strstr($response, "\r\n\r\n")); } } flickrsync_vardump($response); return $response; }
{ ob_start(); var_dump($var); flickrsync_log(ob_get_clean()); } flickrsync_log('chamando require_once phpflickr'); require_once "./lib/phpflickr/phpFlickr.php"; flickrsync_log('require_once phpflickr chamado'); require_once "sensitive_data_wrapper.php"; flickrsync_log('instanciando phpflickr'); $f = new phpFlickr(FLICKR_API_KEY, FLICKR_API_SECRET, true); flickrsync_log('instanciei phpflickr'); flickrsync_vardump($_SESSION); flickrsync_vardump($_GET); if (!empty($_GET['frob'])) { flickrsync_log('achei um frob na variavel get:'); flickrsync_vardump($_GET['frob']); flickrsync_log('getting token by frob'); $auth_token = $f->auth_getToken($_GET['frob']); //$f->setToken( //); } flickrsync_vardump($_SESSION); flickrsync_vardump($_GET); //change this to the permissions you will need if (empty($_SESSION['phpFlickr_auth_token'])) { $f->auth("read"); } else { echo "Copy this token into your code: "; var_dump($_SESSION['phpFlickr_auth_token']); }