Toninho Posted February 27, 2022 at 01:12 PM Report Share #625485 Posted February 27, 2022 at 01:12 PM (edited) Olá, Preciso listar os trabalhos vindos de uma api $output = $jobsAPI->query(array( 'q' => '', 'l' => $_GET['city'], 'start' => 10, 'limit' => 3, 'sort' => 'date', 'co' => 'br' )); $results = $jobsdAPI->query($output); print_r($output->company)."<br>"; print_r($results->company)."<br>"; recebo estes erros Notice: Undefined property: stdClass::$company Notice: Undefined property: stdClass::$company tentei assim também for($i=0;$i<count($results['results']);$i++) { echo "titulo".$results['results'][$i]['jobtitle']; erro Fatal error: Cannot use object of type stdClass as array Agradeço qualquer ajuda Edited February 27, 2022 at 02:42 PM by Toninho Link to comment Share on other sites More sharing options...
washalbano Posted February 27, 2022 at 02:45 PM Report Share #625486 Posted February 27, 2022 at 02:45 PM 1 hour ago, Toninho said: Notice: Undefined property: stdClass::$company Essa mensagem diz que não existe company nem em $output nem em $results dê um var_dump nessas variáveis para ver o conteúdo delas. (talvez company esteja num nível mais profundo dessas variáveis) 1 hour ago, Toninho said: Fatal error: Cannot use object of type stdClass as array Essa mensagem diz que o sr. está tentando usar índice de array em um objeto Array é assim: $array['index'] Objeto é assim: $object->index Link to comment Share on other sites More sharing options...
Toninho Posted February 27, 2022 at 02:53 PM Author Report Share #625487 Posted February 27, 2022 at 02:53 PM Grato pela resposta veja Citação object(stdClass)#13 (13) { ["version"]=> int(2) ["query"]=> string(0) "" ["location"]=> string(8) "Brasilia" ["paginationPayload"]=> string(0) "" ["radius"]=> int(25) ["dupefilter"]=> bool(true) ["highlight"]=> bool(true) ["totalResults"]=> int(4390) ["start"]=> int(11) ["end"]=> int(13) ["pageNumber"]=> int(4) ["estimatedRevenue"]=> int(0) ["results"]=> array(3) { [0]=> object(stdClass)#14 (20) { ["jobtitle"]=> string(9) "Atendente" ["company"]=> string(6) "Jobbol" ["city"]=> string(9) "Brasília" ["state"]=> string(2) "DF" ["country"]=> string(2) "BR" ["language"]=> string(2) "pt" ["formattedLocation"]=> string(13) "Brasília, DF" ["source"]=> string(6) "Jobbol" ["date"]=> string(29) "Fri, 25 Feb 2022 20:47:27 GMT" ["snippet"]=> string(161) "Loja de brinquedos admite Atendente em Brasília para atuar em Tempo integral, Comercial. Atender e orientar clientes quanto ao uso correto dos equipamentos e…" ["url"]=> string(206) "https://br.indeed.com/viewjob?jk=02d2166d76e7bc18&qd=DJ2ck3HrsIqLaTye1exod_vMhcr1H0Jhxmh5j8gHiA-PC2WBv3iMn2jJj179tEZ5J7xJU5ssnKSuz1uo8nF6v1CXRLpjz27zGnJ8ZJ17xL4&indpubnum=17083005191573&atk=1fstqkvevn5b6801" ["onmousedown"]=> string(24) "indeed_clk(this,'3453');" ["jobkey"]=> string(16) "02d2166d76e7bc18" ["sponsored"]=> bool(false) ["expired"]=> bool(false) ["indeedApply"]=> bool(false) ["formattedLocationFull"]=> string(13) "Brasília, DF" ["formattedRelativeTime"]=> string(9) "há 1 dia" ["stations"]=> string(0) "" ["refNum"]=> string(9) "902133214" } [1]=> object(stdClass)#15 (20) { ["jobtitle"]=> string(39) "Auxiliar de Escritório - Vicente Pires" ["company"]=> string(6) "Jobbol" ["city"]=> string(9) "Brasília" ["state"]=> string(2) "DF" ["country"]=> string(2) "BR" ["language"]=> string(2) "pt" ["formattedLocation"]=> string(13) "Brasília, DF" ["source"]=> string(6) "Jobbol" ["date"]=> string(29) "Fri, 25 Feb 2022 20:47:38 GMT" ["snippet"]=> string(155) "Empresa do ramo de cuidados de idosos admite Auxiliar de Escritório em Brasília (Vicente Pires) para atuar em Tempo integral, Segunda-Feira a Sábado.…" ["url"]=> string(206) "https://br.indeed.com/viewjob?jk=2970e07f47328468&qd=DJ2ck3HrsIqLaTye1exod_vMhcr1H0Jhxmh5j8gHiA-PC2WBv3iMn2jJj179tEZ5J7xJU5ssnKSuz1uo8nF6v1CXRLpjz27zGnJ8ZJ17xL4&indpubnum=17083005191573&atk=1fstqkvevn5b6801" ["onmousedown"]=> string(24) "indeed_clk(this,'3453');" ["jobkey"]=> string(16) "2970e07f47328468" ["sponsored"]=> bool(false) ["expired"]=> bool(false) ["indeedApply"]=> bool(false) ["formattedLocationFull"]=> string(13) "Brasília, DF" ["formattedRelativeTime"]=> string(9) "há 1 dia" ["stations"]=> string(0) "" ["refNum"]=> string(9) "902133006" } [2]=> object(stdClass)#16 (20) { ["jobtitle"]=> string(46) "Estoquista/Administrativo – Brasília – DF" ["company"]=> string(13) "Divulga Vagas" ["city"]=> string(9) "Brasília" ["state"]=> string(2) "DF" ["country"]=> string(2) "BR" ["language"]=> string(2) "pt" ["formattedLocation"]=> string(13) "Brasília, DF" ["source"]=> string(13) "Divulga Vagas" ["date"]=> string(29) "Sat, 26 Feb 2022 07:42:52 GMT" ["snippet"]=> string(161) ". 1317,86 Requisitos: Vaga somente para moradores do DF para trabalhar na Cidade do Automóvel Remuneração: R$ 1.317,86 + Vale Alimentação (R$30,00/dia) +…" ["url"]=> string(206) "https://br.indeed.com/viewjob?jk=114e167bc6c981f6&qd=DJ2ck3HrsIqLaTye1exod_vMhcr1H0Jhxmh5j8gHiA-PC2WBv3iMn2jJj179tEZ5J7xJU5ssnKSuz1uo8nF6v1CXRLpjz27zGnJ8ZJ17xL4&indpubnum=17083005191573&atk=1fstqkvevn5b6801" ["onmousedown"]=> string(24) "indeed_clk(this,'3453');" ["jobkey"]=> string(16) "114e167bc6c981f6" ["sponsored"]=> bool(false) ["expired"]=> bool(false) ["indeedApply"]=> bool(false) ["formattedLocationFull"]=> string(13) "Brasília, DF" ["formattedRelativeTime"]=> string(9) "há 1 dia" ["stations"]=> string(0) "" ["refNum"]=> string(8) "14657172" } } } Link to comment Share on other sites More sharing options...
washalbano Posted February 27, 2022 at 07:12 PM Report Share #625488 Posted February 27, 2022 at 07:12 PM 4 hours ago, Toninho said: object(stdClass)#13 (13) { ["version"]=> int(2) ["query"]=> string(0) "" ["location"]=> string(8) "Brasilia" ["paginationPayload"]=> string(0) "" ["radius"]=> int(25) ["dupefilter"]=> bool(true) ["highlight"]=> bool(true) ["totalResults"]=> int(4390) ["start"]=> int(11) ["end"]=> int(13) ["pageNumber"]=> int(4) ["estimatedRevenue"]=> int(0) ["results"]=> array(3) { [0]=> object(stdClass)#14 (20) { ["jobtitle"]=> string(9) "Atendente" ["company"]=> string(6) "Jobbol" ["city"]=> string(9) "Brasília" ["state"]=> string(2) "DF" ["country"]=> string(2) "BR" ["language"]=> string(2) "pt" ["formattedLocation"]=> string(13) "Brasília, DF" ["source"]=> string(6) "Jobbol" ["date"]=> string(29) "Fri, 25 Feb 2022 20:47:27 GMT" ["snippet"]=> string(161) "Loja de brinquedos admite Atendente em Brasília para atuar em Tempo integral, Comercial. Atender e orientar clientes quanto ao uso correto dos equipamentos e…" ["url"]=> string(206) "https://br.indeed.com/viewjob?jk=02d2166d76e7bc18&qd=DJ2ck3HrsIqLaTye1exod_vMhcr1H0Jhxmh5j8gHiA-PC2WBv3iMn2jJj179tEZ5J7xJU5ssnKSuz1uo8nF6v1CXRLpjz27zGnJ8ZJ17xL4&indpubnum=17083005191573&atk=1fstqkvevn5b6801" ["onmousedown"]=> string(24) "indeed_clk(this,'3453');" ["jobkey"]=> string(16) "02d2166d76e7bc18" ["sponsored"]=> bool(false) ["expired"]=> bool(false) ["indeedApply"]=> bool(false) ["formattedLocationFull"]=> string(13) "Brasília, DF" ["formattedRelativeTime"]=> string(9) "há 1 dia" ["stations"]=> string(0) "" ["refNum"]=> string(9) "902133214" } [1]=> object(stdClass)#15 (20) { ["jobtitle"]=> string(39) "Auxiliar de Escritório - Vicente Pires" ["company"]=> string(6) "Jobbol" ["city"]=> string(9) "Brasília" ["state"]=> string(2) "DF" ["country"]=> string(2) "BR" ["language"]=> string(2) "pt" ["formattedLocation"]=> string(13) "Brasília, DF" ["source"]=> string(6) "Jobbol" ["date"]=> string(29) "Fri, 25 Feb 2022 20:47:38 GMT" ["snippet"]=> string(155) "Empresa do ramo de cuidados de idosos admite Auxiliar de Escritório em Brasília (Vicente Pires) para atuar em Tempo integral, Segunda-Feira a Sábado.…" ["url"]=> string(206) "https://br.indeed.com/viewjob?jk=2970e07f47328468&qd=DJ2ck3HrsIqLaTye1exod_vMhcr1H0Jhxmh5j8gHiA-PC2WBv3iMn2jJj179tEZ5J7xJU5ssnKSuz1uo8nF6v1CXRLpjz27zGnJ8ZJ17xL4&indpubnum=17083005191573&atk=1fstqkvevn5b6801" ["onmousedown"]=> string(24) "indeed_clk(this,'3453');" ["jobkey"]=> string(16) "2970e07f47328468" ["sponsored"]=> bool(false) ["expired"]=> bool(false) ["indeedApply"]=> bool(false) ["formattedLocationFull"]=> string(13) "Brasília, DF" ["formattedRelativeTime"]=> string(9) "há 1 dia" ["stations"]=> string(0) "" ["refNum"]=> string(9) "902133006" } [2]=> object(stdClass)#16 (20) { ["jobtitle"]=> string(46) "Estoquista/Administrativo – Brasília – DF" ["company"]=> string(13) "Divulga Vagas" ["city"]=> string(9) "Brasília" ["state"]=> string(2) "DF" ["country"]=> string(2) "BR" ["language"]=> string(2) "pt" ["formattedLocation"]=> string(13) "Brasília, DF" ["source"]=> string(13) "Divulga Vagas" ["date"]=> string(29) "Sat, 26 Feb 2022 07:42:52 GMT" ["snippet"]=> string(161) ". 1317,86 Requisitos: Vaga somente para moradores do DF para trabalhar na Cidade do Automóvel Remuneração: R$ 1.317,86 + Vale Alimentação (R$30,00/dia) +…" ["url"]=> string(206) "https://br.indeed.com/viewjob?jk=114e167bc6c981f6&qd=DJ2ck3HrsIqLaTye1exod_vMhcr1H0Jhxmh5j8gHiA-PC2WBv3iMn2jJj179tEZ5J7xJU5ssnKSuz1uo8nF6v1CXRLpjz27zGnJ8ZJ17xL4&indpubnum=17083005191573&atk=1fstqkvevn5b6801" ["onmousedown"]=> string(24) "indeed_clk(this,'3453');" ["jobkey"]=> string(16) "114e167bc6c981f6" ["sponsored"]=> bool(false) ["expired"]=> bool(false) ["indeedApply"]=> bool(false) ["formattedLocationFull"]=> string(13) "Brasília, DF" ["formattedRelativeTime"]=> string(9) "há 1 dia" ["stations"]=> string(0) "" ["refNum"]=> string(8) "14657172" } } } A partir do object dumped, será preciso entrar em results(perceba que é um array), depois no índice zero e somente depois acessar company: Veja se assim funciona: echo $dumpedObject->results[0]->company; Link to comment Share on other sites More sharing options...
Toninho Posted February 28, 2022 at 10:13 AM Author Report Share #625489 Posted February 28, 2022 at 10:13 AM Grato, funciona $output->results[0]->company $output->results[0]->jobtitle $output->results[0]->city mas esse for não funciona for($i=0;$i<count($output->$results[0]);$i++) { echo $output->$results[0][$i]['jobtitle']; echo $output->$results[0][$i]['company']; echo $output->$results[0][$i]['city']; } 1 Report Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now