Я получаю соединения через API LinkedIn.
Это образец ответа. Все, что я хочу сделать, – это цикл через это с помощью PHP, получив имя и фамилию. Должно быть просто, но я в тупике. Благодарю.
stdClass Object ([_total] => 420 [values] => Array ([0] => stdClass Object ([apiStandardProfileRequest] => stdClass Object ([headers] => stdClass Object ([_total] => 1 [values] = > Array ([0] => stdClass Object ([name] => x-li-auth-token [значение] => name: AnUY))) [url] => http://api.linkedin.com/v1 / people / 7yw8k_sjqf ) [firstName] => John [headline] => Менеджер по финансам в ABC. [id] => 7yw8k_sjqf [industry] => Страхование [lastName] => Doe [location] => stdClass Object ([страна] => stdClass Object ([code] => us) [name] => Greater Atlanta Area) [pictureUrl] => http://mclnkd.licdn.com/mpr/mprx/0_73E_PMM3nzAIZLG03bHpPRo3qvCwZL_0DhYpPRogIxiFs7jUYPVRGNRGC1mGegyyqdihoC [siteStandardProfileRequest] => stdClass Object ([ url] => http://www.linkedin.com/profile/view?id=2633833&authType=name&authToken=AnUY&trk=api * a189561 * s197687 *)) [1] => stdClass Object ([apiStandardProfileRequest] => stdClass Object ( [headers] => stdClass Object ([_total] => 1 [values] => Array ([0] => stdClass Object ([name] => x-li-auth-token [значение] => имя: tpAo))) [url] => http://api.linkedin.com/v1/people/FW8obZbI8R ) [firstName] = > Jeremy [headline] => Владелец, BCD [id] => FW8obZbI8R [industry] => Компьютерное программное обеспечение [lastName] => Doe [location] => stdClass Object ([страна] => stdClass Object ([code] => us) [name] => Greater Chicago Area) [pictureUrl] => http://mclnkd.licdn.com/mpr/mprx/0_Lw2NlImcd1e6LmQpL2mIleOMIcf9LeFpbu4IlexHq-R6V2ryWSpZ0HI6LM7rXeaEYf3Gt69H [siteStandardProfileRequest] => stdClass Object ([url] => http: // www.linkedin.com/profile/view?id=6700159&authType=name&authToken=tpAo&trk=api * a189561 * s197687 *)) [2] => stdClass Object ([apiStandardProfileRequest] => stdClass Object ([headers] => stdClass Object ( [_total] => 1 [values] => Array ([0] => stdClass Object ([name] => x-li-auth-token [значение] => имя: eETp))) [url] => http : //api.linkedin.com/v1/people/a7-dvlvc7K ) [firstName] => Jane [headline] => Sr. Консультация Интеграция системы в AT & T [id] => a7-dvlvc 7K [индустрия] => Телекоммуникации [lastName] => Doe [location] => stdClass Object ([страна] => stdClass Object ([code] => us) [name] => Greater New York City Area) [pictureUrl] => http://mclnkd.licdn.com/mpr/mprx/0_459zxGU8TBpTZjvisicExTgSSvZCsYXisCGExTR-t1ut5V1_N_6JA37p_Z4gJQqIK653RvmW [siteStandardProfileRequest] => stdClass Object ([url] => http://www.linkedin.com/profile/view?id=119413921&authType= имя и authToken = eETp & trk = api * a189561 * s197687 *)) [3] => stdClass Object ([apiStandardProfileRequest] => stdClass Object ([headers] => stdClass Object ([_total] => 1 [values] => Array ([ 0] => stdClass Object ([name] => x-li-auth-token [значение] => имя: HjUG))) [url] => http://api.linkedin.com/v1/people/aie8Zpk9Gm ) [firstName] => John [headline] => Финансовая информация / Данные о рынке Professional [id] => aie8Zpk9Gm [industry] => Финансовые услуги [lastName] => Смит [location] => stdClass Object ([страна] => stdClass Object ([code] => gb) [name] => Глазго, Соединенное Королевство ) [pictureUrl] => http://mclnkd.licdn.com/mpr/mprx/0_N0TLAL3BTlHZCVAbTNTAD03RCjngvsAbCIY-JfOxvg4JldxF9L7MShCp_Avp_ROhKS8LNY [siteStandardProfileRequest] => stdClass Object ([url] => http://www.linkedin.com/profile/view? id = 1562499 & authType = name & authToken = HjUG & trk = api * a189561 * s197687 *)) [4] => stdClass Object ([apiStandardProfileRequest] => stdClass Object ([headers] => stdClass Object ([_total] => 1 [values] = > Array ([0] => stdClass Object ([name] => x-li-auth-token [значение] => имя: aZIS))) [url] => http://api.linkedin.com/v1 / people / XTGgSuagWI ) [firstName] => Bob [headline] => CEO, Nycomed US at NMO [id] => XTGgSuagWI [индустрия] => Фармацевтика [lastName] => коричневый [location] => stdClass Object ([страна ] => stdClass Object ([code] => us) [name] => Greater New York City Area) [pictureUrl] => http://mclnkd.licdn.com/mpr/mprx/0_UciCehxmKngbM15je_qytdVG-zSbJrcje_92S7a-DlsFcA1m6iCGyXsjl-uwsq3ybXXbrd1L [siteStandardProfileRequest] => stdClass Object ([url] =>
То, что у вас есть в качестве ответа, – это stdclass, который будет обладать всеми его свойствами.
Вот как вы его повторяете:
$response = $this->getResponseFromLinkedIn(); foreach ($response->values as $value) { $firstName = $value->firstName; $lastName = $value->lastName; // do something with the extracted values! }