<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Phaneronsoft &#187; correios</title>
	<atom:link href="http://www.phaneronsoft.com/phaneronsoft/tag/correios/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.phaneronsoft.com/phaneronsoft</link>
	<description>Desenvolvimento Web</description>
	<lastBuildDate>Fri, 15 Jul 2011 20:15:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Sistema e manual para Calcular Frete SEDEX, e-SEDEX e PAC dos Correios  (versão 1.1)</title>
		<link>http://www.phaneronsoft.com/phaneronsoft/2010/02/08/sistema-para-calcular-frete-sedex-e-pac-1-1-pac-esta-funcionando/</link>
		<comments>http://www.phaneronsoft.com/phaneronsoft/2010/02/08/sistema-para-calcular-frete-sedex-e-pac-1-1-pac-esta-funcionando/#comments</comments>
		<pubDate>Mon, 08 Feb 2010 14:01:33 +0000</pubDate>
		<dc:creator>Marcelo Korjenioski</dc:creator>
				<category><![CDATA[Ferramentas]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[CEP]]></category>
		<category><![CDATA[correios]]></category>
		<category><![CDATA[Frete]]></category>
		<category><![CDATA[manual]]></category>
		<category><![CDATA[PAC]]></category>
		<category><![CDATA[Sedex]]></category>
		<category><![CDATA[webservice]]></category>

		<guid isPermaLink="false">http://www.phaneronsoft.com/phaneronsoft/?p=427</guid>
		<description><![CDATA[Desde semana passada o antigo webservice dos correios parou de funcionar com PAC. Foi feita a correção do código e agora o PAC esta funcionando novamente. Sistema para Calcular Frete 1.1 Documentação para utilizar o webservice dos Correios para efetuar o calculo de forma personalizada. SCPP_Manual_Implementacao_Calculo_Remoto_de_Precos_e_Prazos Abaixo segue o código para manipular os dados do [...]]]></description>
			<content:encoded><![CDATA[<p>Desde semana passada o antigo webservice dos correios parou de funcionar com PAC.<br />
Foi feita a correção do código e agora o PAC esta funcionando novamente.</p>
<p><a title="Sistema para calcular Frete" href="http://www.phaneronsoft.com/phaneronsoft/2009/05/28/sistema-para-calcular-frete-sedex-e-pac-a-partir-de-cep-informado/" target="_self">Sistema para Calcular Frete 1.1</a></p>
<p>Documentação para utilizar o webservice dos Correios para efetuar o calculo de forma personalizada.</p>
<p><a href="http://www.phaneronsoft.com/phaneronsoft/wp-content/uploads/2010/02/SCPP_Manual_Implementacao_Calculo_Remoto_de_Precos_e_Prazos.pdf">SCPP_Manual_Implementacao_Calculo_Remoto_de_Precos_e_Prazos</a></p>
<p>Abaixo segue o código para manipular os dados do webservice usando o PHP.</p>
<p><a title="Webservice Correios" href="http://www.phaneronsoft.com/exemplos/webservice_correio/correio.php" target="_blank">Segue o exemplo do código abaixo funcionando.</a></p>
<pre class="brush: php">
&lt;?php
/**
* Faz consulta no webservice dos correios e gera array dos valores.
* @copyright  Phaneronsoft
* @author Marcelo Korjenioski - faleconosco@phaneronsoft.com
* @see http://www.phaneronsoft.com
* @filesource correios.php
* @version 1.0
*/

// PESO: Peso total do pacote em Quilos, caso seja menos de 1Kg, ex.: 300g, coloque 0.300
define(&#039;PESO&#039;,0.300);
// COMPRIMENTO: comprimento do volume em centímetros - somente número de 16 a 60
define(&#039;COMPRIMENTO&#039;,30);
// ALTURA: altura do volume em centímetros - somente número de 2 a 60
define(&#039;ALTURA&#039;,15);
// LARGURA: largura do volume em centimetros - somente número de 5 a 60
define(&#039;LARGURA&#039;,20);
// CODIGO_SERVICO: É possivel fazer mais de uma consulta ao mesmo tempo, basta separar os códigos por virgula.
// Neste caso PAC 41106 e SEDEX 40010
define(&#039;CODIGO_SERVICO&#039;,&#039;41106,40010&#039;);
// CEP_ORIGEM: seu CEP com 8 dígitos - somente números
define(&#039;CEP_ORIGEM&#039;,&#039;81010210&#039;);
// CEP_DESTINO: CEP do seu cliente com 8 dígitos - somente números
define(&#039;CEP_DESTINO&#039;,&#039;60245965&#039;);

// Crio um objeto para manipular o XML.
$doc = new DomDocument;
// Carrega o arquivo XML com um arquivo DOMDocument
$doc-&gt;Load(&quot;http://shopping.correios.com.br/wbm/shopping/script/CalcPrecoPrazo.aspx?StrRetorno=xml&amp;amp;nCdServico=&quot; . CODIGO_SERVICO . &quot;&amp;amp;nVlPeso=&quot; . PESO . &quot;&amp;amp;sCepOrigem=&quot; . CEP_ORIGEM . &quot;&amp;amp;sCepDestino=&quot; . CEP_DESTINO . &quot;&amp;amp;nCdFormato=1&amp;amp;nVlComprimento=&quot; . COMPRIMENTO . &quot;&amp;amp;nVlAltura=&quot; . ALTURA . &quot;&amp;amp;nVlLargura=&quot; . LARGURA);
// Defino o nome do elemento pai (root).
$root = $doc-&gt;getElementsByTagName(&#039;cServico&#039;);

// Carrega o arquivo XML com um arquivo DOMDocument
$correios = &quot;http://shopping.correios.com.br/wbm/shopping/script/CalcPrecoPrazo.aspx?StrRetorno=xml&amp;amp;nCdServico=&quot; . CODIGO_SERVICO . &quot;&amp;amp;nVlPeso=&quot; . PESO . &quot;&amp;amp;sCepOrigem=&quot; . CEP_ORIGEM . &quot;&amp;amp;sCepDestino=&quot; . CEP_DESTINO . &quot;&amp;amp;nCdFormato=1&amp;amp;nVlComprimento=&quot; . COMPRIMENTO . &quot;&amp;amp;nVlAltura=&quot; . ALTURA . &quot;&amp;amp;nVlLargura=&quot; . LARGURA;
// Defino o nome do elemento pai (root).
$root = $doc-&gt;getElementsByTagName(&#039;cServico&#039;);

// Defino o nome dos elementos filhos no arquivo XML que eu desejo.
$children = array(&#039;Valor&#039;,&#039;PrazoEntrega&#039;);

// Faço um loop para pegar todos os elementos pai (root) encontrados.
$valor = array();
for ($i=0; $i &lt; $root-&gt;length; $i++) {
// Pega o valor do atributo do elemento pai  (root).
    $id =  $root-&gt;item($i)-&gt;getElementsByTagName(&#039;Codigo&#039;)-&gt;item(0)-&gt;nodeValue;

// Busca por elementos filhos (child) definidos no array
    foreach ($children as $child) {
        $valor[$id][$child] = $root-&gt;item($i)-&gt;getElementsByTagName($child)-&gt;item(0)-&gt;nodeValue;
    }
}
echo &#039;&lt;pre&gt;&#039;;
var_dump($valor);
</pre>
<p>Caso tenha alguma duvida deixe um comen­tá­rio que terei pra­zer em aju­dar.<br />
Comen­tá­rios são bem vin­dos assim posso melho­rar a qua­li­dade dos tuto­ri­ais aqui apresentados.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phaneronsoft.com/phaneronsoft/2010/02/08/sistema-para-calcular-frete-sedex-e-pac-1-1-pac-esta-funcionando/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Sistema para rastrear entregas nos Correios.</title>
		<link>http://www.phaneronsoft.com/phaneronsoft/2009/10/14/sistema-para-rastrear-entregas-nos-correios/</link>
		<comments>http://www.phaneronsoft.com/phaneronsoft/2009/10/14/sistema-para-rastrear-entregas-nos-correios/#comments</comments>
		<pubDate>Wed, 14 Oct 2009 20:13:49 +0000</pubDate>
		<dc:creator>Marcelo Korjenioski</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[correios]]></category>
		<category><![CDATA[entregas]]></category>
		<category><![CDATA[rastrear]]></category>

		<guid isPermaLink="false">http://www.phaneronsoft.com/phaneronsoft/?p=374</guid>
		<description><![CDATA[Olá pessoal depois de um tempo sem postar surgiu uma necessidade de rastrear minhas encomendas nos  Correios. Como não gosto de ficar apertando F5 no site dos Correios que vive com problemas resolvi fazer a consulta via Ajax. O codigo é simples e aproveitei a ideia do sistema para calcular frete. Segue exemplo funcionando. &#60;/p&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>Olá pessoal depois de um tempo sem postar surgiu uma necessidade de rastrear minhas encomendas nos  Correios.</p>
<p>Como não gosto de ficar apertando F5 no site dos Correios que vive com problemas resolvi fazer a consulta via Ajax. O codigo é simples e aproveitei a ideia do <a href="http://www.phaneronsoft.com/phaneronsoft/2009/05/28/sistema-para-calcular-frete-sedex-e-pac-a-partir-de-cep-informado/" target="_blank">sistema para calcular frete</a>.</p>
<p>Segue <a href="http://www.phaneronsoft.com/exemplos/rastrear/rastrear.php">exemplo funcionando</a>.</p>
<pre class="brush: php">&lt;/p&gt;
&lt;?php
if($_POST) {
header(&quot;Content-Type: text/html; charset=ISO-8859-1&quot;);
$p_cod_lis = $_POST[&#039;P_COD_LIS&#039;];
if($p_cod_lis == &#039;&#039;) {
echo &#039;&lt;center&gt;Código não informado&lt;/center&gt;&#039;;
}
$url = &quot;http://websro.correios.com.br/sro_bin/txect01$.Inexistente?P_LINGUA=001&amp;P_TIPO=002&amp;P_COD_LIS=$p_cod_lis&quot;;

$conecurl = @fopen(&quot;$url&quot;,&quot;r&quot;) or die (&#039;&lt;center&gt;erro na conexão&lt;/center&gt;&#039;);
while(!feof($conecurl)) {
$lin .= fgets($conecurl,4096);
}
fclose($conecurl);

$lin = strtolower($lin);

$rest = substr($lin,0);
$nprimetable = strpos($rest,&#039;&lt;table &#039;);
$fechatable = strpos($rest,&#039;&lt;hr &#039;);
$quantopula = $fechatable - $nprimetable ;
$conteudo = substr($lin, $nprimetable ,$quantopula);

function get_anchor($html)
{
$er = &quot;/&lt;td.*?&gt;.*?&lt;\/td&gt;/&quot;;
preg_match_all($er,$html,$links);
$link = $links[0];
return $link;
}

function get_label($url)
{
$label = str_replace(&quot;&lt;/td&gt;&quot;,&quot;&quot;,preg_replace(&quot;/^&lt;td.*?&gt;/&quot;,&quot;&quot;,$url));
return $label;
}

echo $conteudo;

} else {
?&gt;
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=ISO-8859-1&quot; /&gt;
&lt;link href=&quot;http://demo.phaneronsoft.com/img/favicon.ico&quot; rel=&quot;shortcut icon&quot; type=&quot;image/x-icon&quot; /&gt;
&lt;title&gt;Sistema para rastrear entregas no correio. | Phaneronsoft&lt;/title&gt;
&lt;style type=&quot;text/css&quot;&gt;
* {
font-family:&quot;Trebuchet MS&quot;,&quot;Lucida Grande&quot;,Verdana,Tahoma,Helvetica,Arial,sans-serif;
font-size:12px;
font-style:normal;
font-variant:normal;
font-weight:normal;
line-height:normal;
}

body {
background:#FFFFFF none repeat scroll 0 0;
height:100%;
margin:0;
margin-top:20px;
width:100%;
}

div#wrapper {
margin:auto;
position:relative;
width:390px;
z-index:0;
}

.select {
text-transform:uppercase;
width:99%;
border:1px solid #B6B6B6;
display:block;
}

.formSearch fieldset {
border:1px solid #CCCCCC;
margin:0;
padding:0 10px;
}

label {
display:block;
/*float:left;*/
margin-right:4px;
padding-bottom:5px !important;
}

legend {
color:#1E398D;
font-family:&quot;Legacy Sans ITC TT Bold&quot;,&quot;Trebuchet MS&quot;,&quot;Lucida Grande&quot;,Verdana,Tahoma,Helvetica,Arial,sans-serif;
font-size:1.5em;
padding:10px 5px;
}

.button {
background:#F5EED3;
border:1px solid #CCCCCC;
color:#666666;
cursor:pointer;
font-size:12px;
font-weight:bold;
letter-spacing:1px;
margin:10px 0 0;
overflow:visible;
text-transform:uppercase;
width:150px;
}

.formMain .inline {
margin:15px 0 0 !important;
}

.text,  .select,  .textarea, .password {
border:1px solid #B6B6B6;
display:block;
text-transform:uppercase;
}

fieldset span.nameField {
color:#666666;
text-transform:uppercase;
}

h3 {
border-bottom:1px solid #F58220;
margin:0;
padding:0;
}

h3 span {
-x-system-font:none;
color:#1E398D;
font-family:&quot;Legacy Sans ITC TT Bold&quot;,&quot;Trebuchet MS&quot;,&quot;Lucida Grande&quot;,Verdana,Tahoma,Helvetica,Arial,sans-serif;
font-size:1.5em;
font-style:normal;
font-variant:normal;
font-weight:bold;
line-height:normal;
}

#value {
-x-system-font:none;
font-family:&quot;Legacy Sans ITC TT Bold&quot;,&quot;Trebuchet MS&quot;,&quot;Lucida Grande&quot;,Verdana,Tahoma,Helvetica,Arial,sans-serif;
font-size:1.5em;
font-style:normal;
font-variant:normal;
font-weight:bold;
line-height:normal;
text-transform:capitalize;
}

#value table {
margin:0;
padding:0;
border:0;
}

#rastrear {
padding-top:30px;
}

#loading {
display:none;
color:#9B0000;
font-family:&quot;Legacy Sans ITC TT Bold&quot;,&quot;Trebuchet MS&quot;,&quot;Lucida Grande&quot;,Verdana,Tahoma,Helvetica,Arial,sans-serif;
font-size:1.5em;
font-style:normal;
font-variant:normal;
font-weight:bold;
line-height:normal;
text-transform:capitalize;
}

&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;div id=&quot;wrapper&quot;&gt;
&lt;h3&gt;
&lt;span&gt;Rastrear pedido&lt;/span&gt;
&lt;/h3&gt;

&lt;form method=&quot;post&quot; action=&quot;&quot; name=&quot;rastreamentohome&quot; onsubmit=&quot;submitForm(this); return false;&quot;&gt;
&lt;fieldset&gt;
&lt;legend&gt;Identificador do objeto:&lt;/legend&gt;
&lt;label for=&quot;P_COD_LIS&quot;&gt;
&lt;textarea cols=&quot;48&quot; id=&quot;P_COD_LIS&quot; rows=&quot;3&quot; name=&quot;P_COD_LIS&quot;&gt;&lt;/textarea&gt;
&lt;/label&gt;
&lt;label for=&quot;pesquisar&quot;&gt;
&lt;input type=&quot;submit&quot; id=&quot;pesquisar&quot; name=&quot;pesquisar&quot; value=&quot;pesquisar&quot; tabindex=&quot;3&quot; /&gt;
&lt;/label&gt;
&lt;/fieldset&gt;
&lt;/form&gt;

&lt;span id=&quot;value&quot;&gt;&lt;/span&gt;
&lt;span id=&#039;loading&#039;&gt;Pesquisando...&lt;/span&gt;
&lt;/div&gt;
&lt;script src=&quot;http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.3/prototype.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
function submitForm(form) {
/*
usa metodo request() da classe Form da prototype, que serializa os campos
do formulario e submete (por POST como default) para a action especificada no form
*/
function mostrarLoading(){
$(&#039;loading&#039;).style.display = &#039;block&#039;;
$(&#039;value&#039;).innerHTML = &#039; &#039;;
}

form.request({
onLoading:mostrarLoading,
onComplete: function(transport){
/*
se o retorno for diferente de -1, entende-se que nao houve problemas, entao apaga-se
os campos do formulario usando o metodo reset() da classe Form
*/
if(transport.responseText !=-1)  {
$(&#039;loading&#039;).style.display = &#039;none&#039;;
$(&#039;value&#039;).innerHTML = transport.responseText;
} else {
form.reset();
$(&#039;loading&#039;).style.display = &#039;none&#039;;
$(&#039;value&#039;).innerHTML = &#039;Erro ao consultar&#039;;
}
}

});
return false;
}
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
&lt;?php } ?&gt;</pre>
<p>Caso tenha alguma duvida ou suges­tão deixe um comen­tá­rio que terei pra­zer em aju­dar.<br />
Comen­tá­rios são bem vin­dos assim posso melho­rar a qua­li­dade dos tuto­ri­ais aqui apresentados.</p>
<p>É isso pes­soal uma ótima semana e até o próximo post.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phaneronsoft.com/phaneronsoft/2009/10/14/sistema-para-rastrear-entregas-nos-correios/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

