phphtmlgoogle-glassgoogle-mirror-apiaero-glass

Custom HTML static cards using PHP Mirror API -Google Glass


I wish to insert HTML formatted card in Google Glass timeline using Mirror API. I am using PHP PHP Mirror Client API. It takes message and image as argument, and displays that image in the background. Something like this:

 insert_timeline_item($mirror_service, $new_timeline_item, "image/jpeg", file_get_contents($image_url));

Any help about using custom card views with PHP Client library would be highly regarded. Thanks.


Solution

  • The custom card views would be expressed by the HTML that you have set in the $new_timeline_item variable.

    You can design the HTML using the Mirror API Playground at https://developers.google.com/glass/tools-downloads/playground

    You would set this into the $new_timeline_item variable with something like

    $html = '<article class="photo">'.
            '  <img src="attachment:0" width="100%" height="100%">'.
            '  <div class="overlay-gradient-tall-dark"/>'.
            '  <section>'.
            '    <p class="text-auto-size">Based on Hybrid Template</p>'.
            '  </section>'.
            '</article>';
    $new_timeline_item->setHtml( $html );
    

    The img URL of "attachment:0" means to use the first attachment as the image. The rest of the HTML was based on the HTML generated by the "Hybrid" template on the Playground - you can adjust as necessary.