aj123cd Posted June 7, 2013 Share Posted June 7, 2013 This the output I am getting from yahoo contact API How can I grab or get the email address and given name. Please advise me. Thank you for your help OUTPUT { "contacts": { "start": 0, "count": 5, "total": 5, "contact": [ { "isConnection": false, "id": 3, "fields": [ { "id": 6, "type": "yahooid", "value": "raji_kris09", "editedBy": "OWNER", "categories": [ ] }, { "id": 7, "type": "guid", "value": "OEZYDW3EVJJPLQMU3ZFTLYZR7Y", "editedBy": "OWNER", "flags": [ "Y360" ], "categories": [ ], "isConnection": false }, { "id": 5, "type": "name", "value": { "givenName": "Raji", "middleName": "", "familyName": "Krishnan", "prefix": "", "suffix": "", "givenNameSound": "", "familyNameSound": "" }, "editedBy": "OWNER", "categories": [ ] } ] }, { "isConnection": false, "id": 16777218, "fields": [ { "id": 16777220, "type": "yahooid", "value": "medhibhanu", "editedBy": "OWNER", "categories": [ ] }, { "id": 16777219, "type": "name", "value": { "givenName": "Bhanu", "middleName": "", "familyName": "Medhi", "prefix": "", "suffix": "", "givenNameSound": "", "familyNameSound": "" }, "editedBy": "OWNER", "categories": [ ] } ] }, { "isConnection": false, "id": 16777221, "fields": [ { "id": 16777228, "type": "email", "value": ""emailaddress@rediffmail.com", "editedBy": "OWNER", "categories": [ ] }, { "id": 16777227, "type": "name", "value": { "givenName": "bhanushri", "middleName": "", "familyName": "medhi", "prefix": "", "suffix": "", "givenNameSound": "", "familyNameSound": "" }, "editedBy": "OWNER", "categories": [ ] } ] }, { "isConnection": false, "id": 1, "fields": [ { "id": 1, "type": "yahooid", "value": "minu_n_2000", "editedBy": "OWNER", "categories": [ ] }, { "id": 2, "type": "name", "value": { "givenName": "minu", "middleName": "", "familyName": "nair", "prefix": "", "suffix": "", "givenNameSound": "", "familyNameSound": "" }, "editedBy": "OWNER", "categories": [ ] } ] }, { "isConnection": false, "id": 33554436, "fields": [ { "id": 33554441, "type": "email", "value": ""emailaddress@ymail.com", "editedBy": "OWNER", "categories": [ ] }, { "id": 16777226, "type": "yahooid", "value": "emailaddress@ymail.com", "editedBy": "OWNER", "categories": [ ] }, { "id": 33554440, "type": "name", "value": { "givenName": "rekha", "middleName": "", "familyName": "", "prefix": "", "suffix": "", "givenNameSound": "", "familyNameSound": "" }, "editedBy": "OWNER", "categories": [ ] } ] } ] }} Quote Link to comment Share on other sites More sharing options...
DaveyK Posted June 7, 2013 Share Posted June 7, 2013 Looks like a JSON array. You should decode the array from JSON to PHP and then access it like any other array. Quote Link to comment Share on other sites More sharing options...
aj123cd Posted June 7, 2013 Author Share Posted June 7, 2013 Thank You DaveyK. Now I got this out put. How do I get the email from this multi array array(1) { ["contacts"]=> array(4) { ["start"]=> int(0) ["count"]=> int(5) ["total"]=> int(64) ["contact"]=> array(5) { [0]=> array(3) { ["isConnection"]=> bool(false) ["id"]=> int(137) ["fields"]=> array(2) { [0]=> array(6) { ["id"]=> int(47) ["type"]=> string(7) "otherid" ["value"]=> string(20) "emailaddress@hotmail.com" ["editedBy"]=> string(5) "OWNER" ["flags"]=> array(1) { [0]=> string(3) "MSN" } ["categories"]=> array(0) { } } [1]=> array(5) { ["id"]=> int(46) ["type"]=> string(4) "name" ["value"]=> array(7) { ["givenName"]=> string(5) "(Y)vv" ["middleName"]=> string(0) "" ["familyName"]=> string(0) "" ["prefix"]=> string(0) "" ["suffix"]=> string(0) "" ["givenNameSound"]=> string(0) "" ["familyNameSound"]=> string(0) "" } ["editedBy"]=> string(5) "OWNER" ["categories"]=> array(0) { } } } } [1]=> array(3) { ["isConnection"]=> bool(false) ["id"]=> int(16777360) ["fields"]=> array(3) { [0]=> array(5) { ["id"]=> int(16777276) ["type"]=> string(5) "email" ["value"]=> string(23) "emailaddress@hotmail.co.uk" ["editedBy"]=> string(5) "OWNER" ["categories"]=> array(0) { } } [1]=> array(5) { ["id"]=> int(16777274) ["type"]=> string(4) "name" ["value"]=> array(7) { ["givenName"]=> string(7) "aarathy" ["middleName"]=> string(0) "" ["familyName"]=> string(1) "j" ["prefix"]=> string(0) "" ["suffix"]=> string(0) "" ["givenNameSound"]=> string(0) "" ["familyNameSound"]=> string(0) "" } ["editedBy"]=> string(5) "OWNER" ["categories"]=> array(0) { } } [2]=> array(5) { ["id"]=> int(16777275) ["type"]=> string(4) "name" ["value"]=> array(7) { ["givenName"]=> string(7) "aarathy" ["middleName"]=> string(0) "" ["familyName"]=> string(1) "j" ["prefix"]=> string(0) "" ["suffix"]=> string(0) "" ["givenNameSound"]=> string(0) "" ["familyNameSound"]=> string(0) "" } ["editedBy"]=> string(5) "OWNER" ["categories"]=> array(0) { } } } } [2]=> array(3) { ["isConnection"]=> bool(false) ["id"]=> int(126) ["fields"]=> array(2) { [0]=> array(5) { ["id"]=> int(2) ["type"]=> string(7) "yahooid" ["value"]=> string(16) "aditya_kommineni" ["editedBy"]=> string(5) "OWNER" ["categories"]=> array(0) { } } [1]=> array(5) { ["id"]=> int(1) ["type"]=> string(4) "name" ["value"]=> array(7) { ["givenName"]=> string(16) "aditya_kommineni" ["middleName"]=> string(0) "" ["familyName"]=> string(0) "" ["prefix"]=> string(0) "" ["suffix"]=> string(0) "" ["givenNameSound"]=> string(0) "" ["familyNameSound"]=> string(0) "" } ["editedBy"]=> string(5) "OWNER" ["categories"]=> array(0) { } } } } [3]=> array(3) { ["isConnection"]=> bool(false) ["id"]=> int(16777356) ["fields"]=> array(1) { [0]=> array(5) { ["id"]=> int(16777267) ["type"]=> string(5) "email" ["value"]=> string(25) "admissions@buckscc.gov.uk" ["editedBy"]=> string(5) "OWNER" ["categories"]=> array(0) { } } } } [4]=> array(3) { ["isConnection"]=> bool(false) ["id"]=> int(16777386) ["fields"]=> array(1) { [0]=> array(5) { ["id"]=> int(16777305) ["type"]=> string(5) "email" ["value"]=> string(26) "emailaddress@renault.co.uk" ["editedBy"]=> string(5) "OWNER" ["categories"]=> array(0) { } } } } } }} Quote Link to comment Share on other sites More sharing options...
rwhite35 Posted June 7, 2013 Share Posted June 7, 2013 Using the following may help you visualize your array better: echo "<pre>" print_r($your_array); echo "</pre>"; Then to access your data, you would need to loop over the outter array then any sub arrays using foreach($your_array as $value). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.