نیاز به مجوز دارد
یک مکان واحد را با شناسه دریافت می کند. یک نمونه ببینید .
درخواست
درخواست HTTP
GET https://www.googleapis.com/mirror/v1/locations/id
مولفه های
نام پارامتر | ارزش | شرح |
---|---|---|
پارامترهای مسیر | ||
id | string | شناسه مکان یا latest مکان شناخته شده. |
مجوز
این درخواست به مجوز حداقل با یکی از حوزه های زیر نیاز دارد ( در مورد احراز هویت و مجوز بیشتر بخوانید ).
محدوده |
---|
https://www.googleapis.com/auth/glass.timeline |
https://www.googleapis.com/auth/glass.location |
درخواست بدن
با این روش بدنه درخواستی ارائه نکنید.
واکنش
در صورت موفقیت آمیز بودن، این روش یک منبع Locations را در بدنه پاسخ برمی گرداند.
مثال ها
توجه: نمونههای کد موجود برای این روش، همه زبانهای برنامهنویسی پشتیبانیشده را نشان نمیدهند (برای فهرست زبانهای پشتیبانیشده به صفحه کتابخانههای مشتری مراجعه کنید).
جاوا
از کتابخانه سرویس گیرنده جاوا استفاده می کند.
import com.google.api.services.mirror.Mirror; import com.google.api.services.mirror.model.Location; import java.io.IOException; public class MyClass { // ... /** * Print information about the latest known location for the current user. * * @param service Authorized Mirror service. */ public static void printLatestLocation(Mirror service) { try { Location location = service.locations().get("latest").execute(); System.out.println("Location recorded on: " + location.getTimestamp()); System.out.println(" > Lat: " + location.getLatitude()); System.out.println(" > Long: " + location.getLongitude()); System.out.println(" > Accuracy: " + location.getAccuracy() + " meters"); } catch (IOException e) { System.err.println("An error occurred: " + e); } } // ... }
.خالص
از کتابخانه کلاینت دات نت استفاده می کند.
using System; using Google.Apis.Mirror.v1; using Google.Apis.Mirror.v1.Data; public class MyClass { // ... /// <summary> /// Print information about the latest known location for the current user. /// </summary> /// <param name='service'> /// Authorized Mirror service. /// </param> public static void PrintLatestLocation(MirrorService service) { try { Location location = service.Locations.Get("latest").Fetch(); Console.WriteLine("Location recorded on: " + location.Timestamp); Console.WriteLine(" > Lat: " + location.Latitude); Console.WriteLine(" > Long: " + location.Longitude); Console.WriteLine(" > Accuracy: " + location.Accuracy + " meters"); } catch (Exception e) { Console.WriteLine("An error occurred: " + e.Message); } } // ... }
PHP
از کتابخانه مشتری PHP استفاده می کند.
/** * Print information about the latest known location for the current user. * * @param Google_MirrorService $service Authorized Mirror service. */ function printLatestLocation($service) { try { $location = $service->locations->get('latest'); print 'Location recorded on: ' . $location->getTimestamp() . "\n"; print ' > Lat: ' . $location->getLatitude() . "\n"; print ' > Long: ' . $location->getLongitude() . "\n"; print ' > Accuracy: ' . $location->getAccuracy() . " meters\n"; } catch (Exception $e) { print 'An error occurred: ' . $e->getMessage(); } }
پایتون
از کتابخانه کلاینت پایتون استفاده می کند.
from apiclient import errors # ... def print_latest_location(service): """Print information about the latest known location for the current user. Args: service: Authorized Mirror service. """ try: location = service.locations().get(id='latest').execute() print 'Location recorded on: %s' % location.get('timestamp') print ' > Lat: %s' % location.get('latitude') print ' > Long: %s' % location.get('longitude') print ' > Accuracy: %s meters' % location.get('accuracy') except errors.HttpError, e: print 'An error occurred: %s' % e
روبی
از کتابخانه کلاینت Ruby استفاده می کند.
## # Print information about the latest known location for the current user. # # @param [Google::APIClient] client # Authorized client instance. # @return nil def print_latest_location(client) mirror = client.discovered_api('mirror', 'v1') result = client.execute( :api_method => mirror.locations.get, :parameters => { 'id' => 'latest' }) if result.success? location = result.data puts "Location recorded on: #{location.timestamp}" puts " > Lat: #{location.latitude}" puts " > Long: #{location.longitude}" puts " > Accuracy: #{location.accuracy} meters" else puts "An error occurred: #{result.data['error']['message']}" end end
برو
از کتابخانه سرویس گیرنده Go استفاده می کند.
import ( "code.google.com/p/google-api-go-client/mirror/v1" "fmt" ) // PrintLatestLocation prints information about the latest known location for // the current user. func PrintLatestLocation(g *mirror.Service) error { l, err := g.Locations.Get("latest").Do() if err != nil { fmt.Printf("An error occurred: %v\n", err) return err } fmt.Printf("Location recorded on: %s\n", l.Timestamp) fmt.Printf(" > Lat: %s\n", s.Latitude) fmt.Printf(" > Long: %s\n", s.Longitude) fmt.Printf(" > Accuracy: %s meters\n", s.Accuracy) return nil }
HTTP خام
از کتابخانه مشتری استفاده نمی کند.
GET /mirror/v1/locations/latest HTTP/1.1
Authorization: Bearer auth token
نیاز به مجوز دارد
یک مکان واحد را با شناسه دریافت می کند. یک نمونه ببینید .
درخواست
درخواست HTTP
GET https://www.googleapis.com/mirror/v1/locations/id
مولفه های
نام پارامتر | ارزش | شرح |
---|---|---|
پارامترهای مسیر | ||
id | string | شناسه مکان یا latest مکان شناخته شده. |
مجوز
این درخواست به مجوز حداقل با یکی از حوزه های زیر نیاز دارد ( در مورد احراز هویت و مجوز بیشتر بخوانید ).
محدوده |
---|
https://www.googleapis.com/auth/glass.timeline |
https://www.googleapis.com/auth/glass.location |
درخواست بدن
با این روش بدنه درخواستی ارائه نکنید.
واکنش
در صورت موفقیت آمیز بودن، این روش یک منبع Locations را در بدنه پاسخ برمی گرداند.
مثال ها
توجه: نمونههای کد موجود برای این روش، همه زبانهای برنامهنویسی پشتیبانیشده را نشان نمیدهند (برای فهرست زبانهای پشتیبانیشده به صفحه کتابخانههای مشتری مراجعه کنید).
جاوا
از کتابخانه سرویس گیرنده جاوا استفاده می کند.
import com.google.api.services.mirror.Mirror; import com.google.api.services.mirror.model.Location; import java.io.IOException; public class MyClass { // ... /** * Print information about the latest known location for the current user. * * @param service Authorized Mirror service. */ public static void printLatestLocation(Mirror service) { try { Location location = service.locations().get("latest").execute(); System.out.println("Location recorded on: " + location.getTimestamp()); System.out.println(" > Lat: " + location.getLatitude()); System.out.println(" > Long: " + location.getLongitude()); System.out.println(" > Accuracy: " + location.getAccuracy() + " meters"); } catch (IOException e) { System.err.println("An error occurred: " + e); } } // ... }
.خالص
از کتابخانه کلاینت دات نت استفاده می کند.
using System; using Google.Apis.Mirror.v1; using Google.Apis.Mirror.v1.Data; public class MyClass { // ... /// <summary> /// Print information about the latest known location for the current user. /// </summary> /// <param name='service'> /// Authorized Mirror service. /// </param> public static void PrintLatestLocation(MirrorService service) { try { Location location = service.Locations.Get("latest").Fetch(); Console.WriteLine("Location recorded on: " + location.Timestamp); Console.WriteLine(" > Lat: " + location.Latitude); Console.WriteLine(" > Long: " + location.Longitude); Console.WriteLine(" > Accuracy: " + location.Accuracy + " meters"); } catch (Exception e) { Console.WriteLine("An error occurred: " + e.Message); } } // ... }
PHP
از کتابخانه مشتری PHP استفاده می کند.
/** * Print information about the latest known location for the current user. * * @param Google_MirrorService $service Authorized Mirror service. */ function printLatestLocation($service) { try { $location = $service->locations->get('latest'); print 'Location recorded on: ' . $location->getTimestamp() . "\n"; print ' > Lat: ' . $location->getLatitude() . "\n"; print ' > Long: ' . $location->getLongitude() . "\n"; print ' > Accuracy: ' . $location->getAccuracy() . " meters\n"; } catch (Exception $e) { print 'An error occurred: ' . $e->getMessage(); } }
پایتون
از کتابخانه کلاینت پایتون استفاده می کند.
from apiclient import errors # ... def print_latest_location(service): """Print information about the latest known location for the current user. Args: service: Authorized Mirror service. """ try: location = service.locations().get(id='latest').execute() print 'Location recorded on: %s' % location.get('timestamp') print ' > Lat: %s' % location.get('latitude') print ' > Long: %s' % location.get('longitude') print ' > Accuracy: %s meters' % location.get('accuracy') except errors.HttpError, e: print 'An error occurred: %s' % e
روبی
از کتابخانه کلاینت Ruby استفاده می کند.
## # Print information about the latest known location for the current user. # # @param [Google::APIClient] client # Authorized client instance. # @return nil def print_latest_location(client) mirror = client.discovered_api('mirror', 'v1') result = client.execute( :api_method => mirror.locations.get, :parameters => { 'id' => 'latest' }) if result.success? location = result.data puts "Location recorded on: #{location.timestamp}" puts " > Lat: #{location.latitude}" puts " > Long: #{location.longitude}" puts " > Accuracy: #{location.accuracy} meters" else puts "An error occurred: #{result.data['error']['message']}" end end
برو
از کتابخانه سرویس گیرنده Go استفاده می کند.
import ( "code.google.com/p/google-api-go-client/mirror/v1" "fmt" ) // PrintLatestLocation prints information about the latest known location for // the current user. func PrintLatestLocation(g *mirror.Service) error { l, err := g.Locations.Get("latest").Do() if err != nil { fmt.Printf("An error occurred: %v\n", err) return err } fmt.Printf("Location recorded on: %s\n", l.Timestamp) fmt.Printf(" > Lat: %s\n", s.Latitude) fmt.Printf(" > Long: %s\n", s.Longitude) fmt.Printf(" > Accuracy: %s meters\n", s.Accuracy) return nil }
HTTP خام
از کتابخانه مشتری استفاده نمی کند.
GET /mirror/v1/locations/latest HTTP/1.1
Authorization: Bearer auth token