php
Transmissão ao vivo do I Encontro|PHPSP
Feb 6th
Amanhã transmitiremos ao vivo o I Encontro|PHPSP!
Você pode ver o live stream pelo site do PHPSP ou acompanhar o twitter procurando pela tag #phpsp.
Twitters @phpsp e @ivanrosolen serão atualizados frequentemente.
I Encontro|PHPSP
Jan 12th
7 Things
Jan 7th
Seven Things you might not know about me …. and I don’t know if you should
Ivo Nascimento from http://www.ianntech.com.br/ tagged me with this #7things!
Now I’ll surprise you with 7 things that are ’strange’ about me
- I do have a degree (take that Ivo) and I’m finishing my MBA …. Only need to finish my ‘TCC’
- I don’t have ZCE …. But I’ll get it this year too in order to my so called friends stop buggin me
- I am a stunt man …. Always in to extreme sport and kung fu led me to become a crazy man
- I listen to ALL kind of music …. I LIKE good old rock’n roll but if there’s music, I’ll have fun
- I used to drink a hole bottle of tequila …. No salt, no lemon and didn’t get drunk. Nowadays a shot makes me fall.
- I never read a tecnical book …. Maybe some day I’ll manage to read at least one PHP book
- I have 7 tattoos …. People say that I’m a coloring book. And I’ll do a back piece in feburary
Now I need to tag 7 friends, but almost everybody is tagged so I’ll tag only this guy:
João Vagner because he have a host, is a good programer and a awesome designer
Follow these rules:
Link your original tagger(s), and list these rules on your blog.
Share seven facts about yourself in the post — some random, some weird.
Tag seven people at the end of your post by leaving their names and the links to their blogs.
Let them know they’ve been tagged by leaving a comment on their blogs and/or Twitter.
Status Correios
Dec 12th
Meu amigo precisava de uma ajuda para recuperar os status que o Correios gera para as encomendas.
Lembrei que havia feito isso na última empresa que trabalhei e agora resolvi compartilhar.
Não é 100% garantido, pois eu leio via REGEX o source da página ok?
Após recuperar o source HTML da página do Correios via cURL ou file_get_contents, utilizo a seguinte função para tratar o conteúdo e retornar um array contendo os dados do Correios.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | <?php /** * Retorna todos os status do Correios para ID enviado * * @param string $id_correios ID do Correios * @return array $array_retorno */ function status_correios( $id_correios ) { $conteudo = file_get_contents('http://websro.correios.com.br/sro_bin/txect01$.QueryList?P_LINGUA=001&P_TIPO=001&P_COD_UNI='.$id_correios); if ( empty($conteudo) ) return false; $array_retorno = array(); preg_match_all( '/<tr>\s*<td[^>]*>(.*)<\/td>\s*<\/tr>/' , $conteudo , $array_regex ); if ( !is_array($array_regex) || count($array_regex) <= 0 ) return false; foreach ( $array_regex[ 1 ] as $key => $linha ) { $foo = explode( '</td><td>' , $linha ); if ( strip_tags( $foo[ 2 ] ) ) { $array_retorno[] = array( strip_tags( $foo[ 0 ] ), strip_tags( $foo[ 1 ] ), strip_tags( $foo[ 2 ] ) ); } } return $array_retorno; } ?> |
ps.: tentei colocar o código fonte completo aqui mas foi humanamente impossível.
Utilizei esse método pois tratava o array com os dados e armazenava em um banco de dados. Caso queria apenas exibir o João Vagner me mostrou esse link.
Dúvidas? Só enviar um email ou perguntar nos comentários.