Question

php hack here, working with the php quick start project. Up to this point I've been using the basic contact added by default. I'm able to share a photo with that contact and post the photo along with the latitude/longitude to Wordpress, it's working great.

However, I would like to insert a contact with a few of the optional properties, but am having a hard time figuring out the best way to go about doing that. I would like to add:

  1. acceptCommands[].type property with a value of TAKE_A_NOTE
  2. sharingFeatures[] with a value of ADD_CAPTION

It doesn't look like the insert_contact function is setup for those options. Do I need to modify that function to pass in the additional properties I want? I'm a little confused on the format needed for acceptCommands[].type. It says string is required but when I look at the output at the top of /glass/v1/reference/contacts - it looks like an array.

Can someone please help to get me pointed in the right direction?

Was it helpful?

Solution

Make sure you have downloaded the latest google-api-php-client (https://github.com/google/google-api-php-client appears to be the authoritative source now). There was a change intoduced with XE8 that was incorporated into version 0.6.6 which enabled sharingFeatures - 0.6.6 is the minimum version necessary for these features, and it is part of the QuickStart example. (Note that there have been some changes in the 1.0 client, but they are mostly naming changes. See https://developers.google.com/api-client-library/php/guide/migration for details about the changes.)

I'm not quite sure what you're asking about acceptCommands. In PHP terms, this should be an array of arrays. (Or a numeric based array, each consisting of associative arrays mapping from a string (currently the value "type") to a string (either the strings "TAKE_A_NOTE" or "POST_AN_UPDATE").

I haven't tested this, but if you wanted your contact to work with both voice commands (for example), you should be able to use code something like this:

$acceptCommands =
    array(
          array("type" => "TAKE_A_NOTE"),
          array("type" => "POST_AN_UPDATE")
          );
$contact->setAcceptCommands( $acceptCommands );
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top