{"id":64,"date":"2017-10-01T10:15:51","date_gmt":"2017-10-01T07:15:51","guid":{"rendered":"http:\/\/lyubomir-angelov.com\/?p=64"},"modified":"2017-09-25T13:43:36","modified_gmt":"2017-09-25T10:43:36","slug":"connect-google-apis","status":"publish","type":"post","link":"https:\/\/lyubomir-angelov.com\/blog\/connect-google-apis\/","title":{"rendered":"How to connect to Google APIs"},"content":{"rendered":"<p>I had small issue searching for the right way connecting to Google Cloud APIs, that&#8217;s why I want to show you how to connect with an example for Vision API, you can find that the steps are easy but I will list them.<\/p>\n<p><!--more--><\/p>\n<ul>\n<li>Create Google account and API key in https:\/\/console.developers.google.com\/apis\/credentials<\/li>\n<li>Enable Google Cloud Vision API or any other that you need<\/li>\n<li>Create Service account key https:\/\/console.developers.google.com\/iam-admin\/serviceaccounts\/<\/li>\n<ul>\n<li>You will receive JSON file which has to be stored somewhere in the project<\/li>\n<li>Set the path to this JSON in global environment variable, with PHP is like this\n<pre class=\"language-php\"><code>putenv(&#039;GOOGLE_APPLICATION_CREDENTIALS=&#039; . realpath(&#039;.\/path-to-the-JSON-file.json&#039;));<\/code><\/pre>\n<\/li>\n<\/ul>\n<li>Run <code>composer require google\/cloud<\/code> to download Google APIs<\/li>\n<li>Then in your PHP file you can do <code>use  Google\\Cloud\\Vision\\VisionClient<\/code> or the API that you need<\/li>\n<li>Creating instance of the API\n<pre class=\"language-php\"><code>\n $vision = new VisionClient(\n            [\n                &#039;projectId&#039; =&gt; &#039;YOUR-API-KEY&#039;,\n            ]\n        );\n<\/code><\/pre>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>I had small issue searching for the right way connecting to Google Cloud APIs, that&#8217;s why I want to show you how to connect with an example for Vision API, you can find that the steps are easy but I will list them.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-64","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to connect to Google APIs - Lyubomir Angelov<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/lyubomir-angelov.com\/blog\/connect-google-apis\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to connect to Google APIs - Lyubomir Angelov\" \/>\n<meta property=\"og:description\" content=\"I had small issue searching for the right way connecting to Google Cloud APIs, that&#8217;s why I want to show you how to connect with an example for Vision API, you can find that the steps are easy but I will list them.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/lyubomir-angelov.com\/blog\/connect-google-apis\/\" \/>\n<meta property=\"og:site_name\" content=\"Lyubomir Angelov\" \/>\n<meta property=\"article:published_time\" content=\"2017-10-01T07:15:51+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-09-25T10:43:36+00:00\" \/>\n<meta name=\"author\" content=\"Lyubomir\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@angelovcode\" \/>\n<meta name=\"twitter:site\" content=\"@angelovcode\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Lyubomir\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/lyubomir-angelov.com\/blog\/connect-google-apis\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/lyubomir-angelov.com\/blog\/connect-google-apis\/\"},\"author\":{\"name\":\"Lyubomir\",\"@id\":\"https:\/\/lyubomir-angelov.com\/blog\/#\/schema\/person\/5e091f5c2fa79f57d30d482a7ef8cd92\"},\"headline\":\"How to connect to Google APIs\",\"datePublished\":\"2017-10-01T07:15:51+00:00\",\"dateModified\":\"2017-09-25T10:43:36+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/lyubomir-angelov.com\/blog\/connect-google-apis\/\"},\"wordCount\":139,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/lyubomir-angelov.com\/blog\/#\/schema\/person\/5e091f5c2fa79f57d30d482a7ef8cd92\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/lyubomir-angelov.com\/blog\/connect-google-apis\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/lyubomir-angelov.com\/blog\/connect-google-apis\/\",\"url\":\"https:\/\/lyubomir-angelov.com\/blog\/connect-google-apis\/\",\"name\":\"How to connect to Google APIs - Lyubomir Angelov\",\"isPartOf\":{\"@id\":\"https:\/\/lyubomir-angelov.com\/blog\/#website\"},\"datePublished\":\"2017-10-01T07:15:51+00:00\",\"dateModified\":\"2017-09-25T10:43:36+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/lyubomir-angelov.com\/blog\/connect-google-apis\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/lyubomir-angelov.com\/blog\/connect-google-apis\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/lyubomir-angelov.com\/blog\/connect-google-apis\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/lyubomir-angelov.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to connect to Google APIs\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/lyubomir-angelov.com\/blog\/#website\",\"url\":\"https:\/\/lyubomir-angelov.com\/blog\/\",\"name\":\"Lyubomir Angelov\",\"description\":\"The life of a Manager\",\"publisher\":{\"@id\":\"https:\/\/lyubomir-angelov.com\/blog\/#\/schema\/person\/5e091f5c2fa79f57d30d482a7ef8cd92\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/lyubomir-angelov.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/lyubomir-angelov.com\/blog\/#\/schema\/person\/5e091f5c2fa79f57d30d482a7ef8cd92\",\"name\":\"Lyubomir\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/lyubomir-angelov.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/f6b8c15868355fa857fad18647aeadd07814e3d9baa72a1c92e718056684fec7?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/f6b8c15868355fa857fad18647aeadd07814e3d9baa72a1c92e718056684fec7?s=96&d=mm&r=g\",\"caption\":\"Lyubomir\"},\"logo\":{\"@id\":\"https:\/\/lyubomir-angelov.com\/blog\/#\/schema\/person\/image\/\"},\"sameAs\":[\"https:\/\/twitter.com\/angelovcode\"],\"url\":\"https:\/\/lyubomir-angelov.com\/blog\/author\/superfly\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to connect to Google APIs - Lyubomir Angelov","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/lyubomir-angelov.com\/blog\/connect-google-apis\/","og_locale":"en_US","og_type":"article","og_title":"How to connect to Google APIs - Lyubomir Angelov","og_description":"I had small issue searching for the right way connecting to Google Cloud APIs, that&#8217;s why I want to show you how to connect with an example for Vision API, you can find that the steps are easy but I will list them.","og_url":"https:\/\/lyubomir-angelov.com\/blog\/connect-google-apis\/","og_site_name":"Lyubomir Angelov","article_published_time":"2017-10-01T07:15:51+00:00","article_modified_time":"2017-09-25T10:43:36+00:00","author":"Lyubomir","twitter_card":"summary_large_image","twitter_creator":"@angelovcode","twitter_site":"@angelovcode","twitter_misc":{"Written by":"Lyubomir","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/lyubomir-angelov.com\/blog\/connect-google-apis\/#article","isPartOf":{"@id":"https:\/\/lyubomir-angelov.com\/blog\/connect-google-apis\/"},"author":{"name":"Lyubomir","@id":"https:\/\/lyubomir-angelov.com\/blog\/#\/schema\/person\/5e091f5c2fa79f57d30d482a7ef8cd92"},"headline":"How to connect to Google APIs","datePublished":"2017-10-01T07:15:51+00:00","dateModified":"2017-09-25T10:43:36+00:00","mainEntityOfPage":{"@id":"https:\/\/lyubomir-angelov.com\/blog\/connect-google-apis\/"},"wordCount":139,"commentCount":0,"publisher":{"@id":"https:\/\/lyubomir-angelov.com\/blog\/#\/schema\/person\/5e091f5c2fa79f57d30d482a7ef8cd92"},"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/lyubomir-angelov.com\/blog\/connect-google-apis\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/lyubomir-angelov.com\/blog\/connect-google-apis\/","url":"https:\/\/lyubomir-angelov.com\/blog\/connect-google-apis\/","name":"How to connect to Google APIs - Lyubomir Angelov","isPartOf":{"@id":"https:\/\/lyubomir-angelov.com\/blog\/#website"},"datePublished":"2017-10-01T07:15:51+00:00","dateModified":"2017-09-25T10:43:36+00:00","breadcrumb":{"@id":"https:\/\/lyubomir-angelov.com\/blog\/connect-google-apis\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/lyubomir-angelov.com\/blog\/connect-google-apis\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/lyubomir-angelov.com\/blog\/connect-google-apis\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/lyubomir-angelov.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to connect to Google APIs"}]},{"@type":"WebSite","@id":"https:\/\/lyubomir-angelov.com\/blog\/#website","url":"https:\/\/lyubomir-angelov.com\/blog\/","name":"Lyubomir Angelov","description":"The life of a Manager","publisher":{"@id":"https:\/\/lyubomir-angelov.com\/blog\/#\/schema\/person\/5e091f5c2fa79f57d30d482a7ef8cd92"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/lyubomir-angelov.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/lyubomir-angelov.com\/blog\/#\/schema\/person\/5e091f5c2fa79f57d30d482a7ef8cd92","name":"Lyubomir","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/lyubomir-angelov.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/f6b8c15868355fa857fad18647aeadd07814e3d9baa72a1c92e718056684fec7?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/f6b8c15868355fa857fad18647aeadd07814e3d9baa72a1c92e718056684fec7?s=96&d=mm&r=g","caption":"Lyubomir"},"logo":{"@id":"https:\/\/lyubomir-angelov.com\/blog\/#\/schema\/person\/image\/"},"sameAs":["https:\/\/twitter.com\/angelovcode"],"url":"https:\/\/lyubomir-angelov.com\/blog\/author\/superfly\/"}]}},"_links":{"self":[{"href":"https:\/\/lyubomir-angelov.com\/blog\/wp-json\/wp\/v2\/posts\/64","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lyubomir-angelov.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lyubomir-angelov.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lyubomir-angelov.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lyubomir-angelov.com\/blog\/wp-json\/wp\/v2\/comments?post=64"}],"version-history":[{"count":3,"href":"https:\/\/lyubomir-angelov.com\/blog\/wp-json\/wp\/v2\/posts\/64\/revisions"}],"predecessor-version":[{"id":69,"href":"https:\/\/lyubomir-angelov.com\/blog\/wp-json\/wp\/v2\/posts\/64\/revisions\/69"}],"wp:attachment":[{"href":"https:\/\/lyubomir-angelov.com\/blog\/wp-json\/wp\/v2\/media?parent=64"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lyubomir-angelov.com\/blog\/wp-json\/wp\/v2\/categories?post=64"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lyubomir-angelov.com\/blog\/wp-json\/wp\/v2\/tags?post=64"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}