monkeytooth Posted June 29, 2011 Share Posted June 29, 2011 Alright, I need some fresh eyes, minds, etc to help me trouble shoot this. First the code.. <?php error_reporting(E_ALL); $user = "xxxxxxxxxxx@gmail.com"; $password = "xxxxxxxxxxx"; // ref: http://code.google.com/apis/accounts/docs/AuthForInstalledApps.html // step 1: login $login_url = "https://www.google.com/accounts/ClientLogin"; $fields = array( 'Email' => $user, 'Passwd' => $password, 'service' => 'cp', // <== contact list service code 'source' => 'test-google-contact-grabber', 'accountType' => 'GOOGLE', ); $curl = curl_init(); curl_setopt($curl, CURLOPT_URL,$login_url); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS,$fields); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec($curl); $returns = array(); foreach (explode("\n",$result) as $line) { $line = trim($line); if (!$line) continue; list($k,$v) = explode("=",$line,2); $returns[$k] = $v; } curl_close($curl); // step 2: grab the contact list $feed_url = "http://www.google.com/m8/feeds/contacts/$user/full?alt=json&max-results=99999"; $header = array( 'Authorization: GoogleLogin auth=' . $returns['Auth'], ); $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $feed_url); curl_setopt($curl, CURLOPT_HTTPHEADER, $header); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec($curl); curl_close($curl); $data = json_decode($result); $contacts = array(); foreach ($data->feed->entry as $entry) { $contact = new stdClass(); $contact->title = $entry->title->{'$t'}; $contact->email = $entry->{'gd$email'}[0]->address; $contacts[] = $contact; } echo '<pre>'; var_dump($contacts); echo '</pre>'; the output.. http://7pz.net/gmail.php the error(s).. Notice: Undefined property: stdClass::$gd$email in /home/monkey/public_html/sites/mine/7pz.net/gmail.php on line 63 Notice: Trying to get property of non-object in /home/monkey/public_html/sites/mine/7pz.net/gmail.php on line 63 Notice: Undefined property: stdClass::$gd$email in /home/monkey/public_html/sites/mine/7pz.net/gmail.php on line 63 Notice: Trying to get property of non-object in /home/monkey/public_html/sites/mine/7pz.net/gmail.php on line 63 Gotta say, Im a bit lost.. Oh and "Line 63" is $contact->email = $entry->{'gd$email'}[0]->address; Quote Link to comment https://forums.phpfreaks.com/topic/240687-gmail-curl-stdclass-issue/ Share on other sites More sharing options...
Adam Posted June 29, 2011 Share Posted June 29, 2011 Can you show us a sample of the JSON data you're working with? Quote Link to comment https://forums.phpfreaks.com/topic/240687-gmail-curl-stdclass-issue/#findComment-1236220 Share on other sites More sharing options...
monkeytooth Posted June 29, 2011 Author Share Posted June 29, 2011 It won't let me post here way to many characters for the post apparently.. So I modified the link I original provided: http://7pz.net/gmail.php It now shows 2 textarea's with the raw json dump and the json decoded dump Quote Link to comment https://forums.phpfreaks.com/topic/240687-gmail-curl-stdclass-issue/#findComment-1236525 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.