Foros del Web » Programando para Internet » PHP »

Problema acceder objeto.

Estas en el tema de Problema acceder objeto. en el foro de PHP en Foros del Web. Hola phpperos, Estoy trabajando con el api de google, el caso es que tengo un duda a la hora de acceser el objeto del páginado ...
  #1 (permalink)  
Antiguo 13/08/2014, 18:14
 
Fecha de Ingreso: septiembre-2011
Mensajes: 176
Antigüedad: 13 años, 2 meses
Puntos: 0
Problema acceder objeto.

Hola phpperos,

Estoy trabajando con el api de google, el caso es que tengo un duda a la hora de acceser el objeto del páginado y me estoy haciendo un lio.

Para acceder a los resultados bien, y me muestra los resultados en array:
$results = $obj->responseData->results;

pero para acceder ahora a las paginas me estoy liando .

$paginas = $obj->cursor->pages;



Muestro la salida del $obj :


Código PHP:
Ver original
  1. stdClass Object ( [responseData] => stdClass Object ( [results] => Array ( [0] => stdClass Object ( [GsearchResultClass] => GwebSearch [unescapedUrl] => http://www.google.com/ [url] => http://www.google.com/ [visibleUrl] => www.google.com [cacheUrl] => http://www.google.com/search?q=cache:zhool8dxBV4J:www.google.com [title] => Google [titleNoFormatting] => Google [content] => Search the world's information, including webpages, images, videos and more. Google has many special features to help you find exactly what you're looking ... ) [1] => stdClass Object ( [GsearchResultClass] => GwebSearch [unescapedUrl] => https://maps.google.com/ [url] => https://maps.google.com/ [visibleUrl] => maps.google.com [cacheUrl] => http://www.google.com/search?q=cache:SK7Wkfiy_5IJ:maps.google.com [title] => Google Maps [titleNoFormatting] => Google Maps [content] => Find local businesses, view maps and get driving directions in ... ) [2] => stdClass Object ( [GsearchResultClass] => GwebSearch [unescapedUrl] => https://mail.google.com/ [url] => https://mail.google.com/ [visibleUrl] => mail.google.com [cacheUrl] => http://www.google.com/search?q=cache:H5kavzmB0oUJ:mail.google.com [title] => Gmail - Email from Google [titleNoFormatting] => Gmail - Email from Google [content] => Gmail's inbox helps you stay organized by sorting your mail by type. Plus, you ... ) [3] => stdClass Object ( [GsearchResultClass] => GwebSearch [unescapedUrl] => http://news.google.com/ [url] => http://news.google.com/ [visibleUrl] => news.google.com [cacheUrl] => http://www.google.com/search?q=cache:Va_XShOz_twJ:news.google.com [title] => Google News [titleNoFormatting] => Google News [content] => Aggregated headlines and a search engine of many of the ... ) [4] => stdClass Object ( [GsearchResultClass] => GwebSearch [unescapedUrl] => http://translate.google.com/ [url] => http://translate.google.com/ [visibleUrl] => translate.google.com [cacheUrl] => http://www.google.com/search?q=cache:Hzpd6vNFcrsJ:translate.google.com [title] => Google Translate [titleNoFormatting] => Google Translate [content] => Google's free online language translation service instantly translates text and web ... Translate. English. Spanish. French. Detect language. Detect language, — ... ) [5] => stdClass Object ( [GsearchResultClass] => GwebSearch [unescapedUrl] => http://scholar.google.com/ [url] => http://scholar.google.com/ [visibleUrl] => scholar.google.com [cacheUrl] => http://www.google.com/search?q=cache:H69r3UFGwP8J:scholar.google.com [title] => Google Scholar [titleNoFormatting] => Google Scholar [content] => Advanced Scholar Search. Articles ( include patents ) Case law. Federal courts ) [6] => stdClass Object ( [GsearchResultClass] => GwebSearch [unescapedUrl] => http://en.wikipedia.org/wiki/Google [url] => http://en.wikipedia.org/wiki/Google [visibleUrl] => en.wikipedia.org [cacheUrl] => http://www.google.com/search?q=cache:EUHTWaMoRSgJ:en.wikipedia.org [title] => Google - Wikipedia, the free encyclopedia [titleNoFormatting] => Google - Wikipedia, the free encyclopedia [content] => Google /ɡuːɡ(ə)l/ is an American multinational corporation specializing in Internet-related services and products. These include online advertising ... ) [7] => stdClass Object ( [GsearchResultClass] => GwebSearch [unescapedUrl] => http://adwords.google.com/ [url] => http://adwords.google.com/ [visibleUrl] => adwords.google.com [cacheUrl] => http://www.google.com/search?q=cache:kTgZovX4ueAJ:adwords.google.com [title] => Google AdWords – Online advertising by Google [titleNoFormatting] => Google AdWords – Online advertising by Google [content] => Advertise with Google AdWords ads next to Google search results to boost ... ) ) [cursor] => stdClass Object ( [resultCount] => 923,000,000 [pages] => Array ( [0] => stdClass Object ( [start] => 0 [label] => 1 ) [1] => stdClass Object ( [start] => 8 [label] => 2 ) [2] => stdClass Object ( [start] => 16 [label] => 3 ) [3] => stdClass Object ( [start] => 24 [label] => 4 ) [4] => stdClass Object ( [start] => 32 [label] => 5 ) [5] => stdClass Object ( [start] => 40 [label] => 6 ) [6] => stdClass Object ( [start] => 48 [label] => 7 ) [7] => stdClass Object ( [start] => 56 [label] => 8 ) ) [estimatedResultCount] => 923000000 [currentPageIndex] => 0 [moreResultsUrl] => http://www.google.com/search?oe=utf8&ie=utf8&source=uds&start=0&hl=en&q=Google [searchResultTime] => 0.16 ) ) [responseDetails] => [responseStatus] => 200 )
  #2 (permalink)  
Antiguo 13/08/2014, 23:05
 
Fecha de Ingreso: septiembre-2011
Mensajes: 176
Antigüedad: 13 años, 2 meses
Puntos: 0
Respuesta: Problema acceder objeto.

Hola ya lo solucioné:

$pages = $obj->responseData->cursor->pages;

ADios

Etiquetas: Ninguno
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 21:46.