* (podem ser obtidas no perfil do usuário "dono" do aplicativo em http://www.apontador.com.br) * * Copyright 2010 Carlos Duarte do Nascimento (Chester) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http: *www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ // // PREENCHA SEUS DADOS AQUI! function apontadorGetConfig() { if ($_SERVER['HTTP_HOST'] != 'localhost') { return array("email" => "*****@*****.**", "key" => "36gcCCI_nv1kQrWTGjnXCBfgVjlCT8KITrkOp_HcopA~", "secret" => "q5_prXzkYCfpr9EB8k4br5ec8uE~", "callbackurl" => "http://apontador.ricardomartins.info/upload_multiplo/callback.php"); } else { return array("email" => "*****@*****.**", "key" => "36gcCCI_nv2NKa5aEz4RA_9tJYkrnnPS__o_fgRn4uE~", "secret" => "WDqV7pv0VZLum53kTuCJN6Ji5vc~", "callbackurl" => "http://localhost/apontador/upload_multiplo/callback.php"); } } $apontadorConfigTeste = apontadorGetConfig(); if (!$apontadorConfigTeste["email"]) { die("Por favor, cadastre sua aplicação no apontador e coloque seus dados no arquivo ApontadorApiConfig.php"); }
/** * Efetua uma chamada a um método API * * @param verbo string GET, POST, PUT ou DELETE, conforme o método/intenção * @param metodo string path do métdodo, sem "/" no começo (ex.: "users/self") * @param params mixed parâmetros da chamada (array associativo) * @param oauth_token string token de autorização do usuário. Se omitido, a chamada usa HTTP Basic Auth * @param oauth_token_secret string secret do token de autorização do usuário (ignorado se oauth_token não for passado) * @return resultado da chamada. */ function apontadorChamaApi($verbo = "GET", $metodo, $params = array(), $oauth_token = "", $oauth_token_secret = "") { extract(apontadorGetConfig()); $endpoint = "http://api.apontador.com.br/v1/{$metodo}"; if (!$oauth_token) { $queryparams = http_build_query($params); $auth_hash = base64_encode("{$email}:{$key}"); return _post("{$endpoint}?{$queryparams}", "GET", null, "Authorization: {$auth_hash}"); } else { // OAuth $consumer = new OAuthConsumer($key, $secret, NULL); $token = new OAuthConsumer($oauth_token, $oauth_token_secret); $signature_method = new OAuthSignatureMethod_HMAC_SHA1(); $req_req = OAuthRequest::from_consumer_and_token($consumer, $token, $verbo, $endpoint, $params); $req_req->sign_request($signature_method, $consumer, $token); if ($verbo == "GET") { return _post($req_req, $verbo); } else { return _post($endpoint, $verbo, $req_req->to_postdata()); } } }