douhuang7263 2019-05-01 20:59 采纳率: 100%
浏览 56

如何在PHP中启动OAuth 2.0 for Content API for Shopping on WordPress?

I figured out the GET request and have the OAuth 2.0 account from Google setup properly, have the credentials and everything else.

However I struggle turning my logic now into a PHP script so I can effectively use it as a WordPress plugin to retrieve Google Shopping orders from the merchant center into WooCommerce.

Sadly Googles Documentation is inconsistent. I tried this under 'Authorization Example': https://developers.google.com/shopping-content/v2/how-tos/authorizing

However then I spotted the google-api-php-client that another documentation said was required: https://github.com/googleapis/google-api-php-client

I downloaded the library as I'm not working with a composer but rather directly in the source code since I intend to put it directly on the server as a call out within WordPress.

I put the library within my ChildTheme unzipped as google-api-php-client-2.2.2

Which meant that the required path became:

require_once '/wp-content/themes/<childtheme>/google-api-php-client/vendor/autoload.php';

And the response I get is: '...failed to open stream...'

The original request that I want to make use of:

GET https://www.googleapis.com/content/v2/<merchant_id>/orders

Postman initiates via 'Request Token' the screen that allows to put in all the information required. I however struggle figuring out how to start an OAuth 2.0 request via PHP.

The desired output is to launch an OAuth 2.0 Request so I can continue to get my orders displayed from the Google Merchant Center under the Google Shopping (also known as 'Google Express') on my WordPress site in the admin backend.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
    • ¥50 有数据,怎么用matlab求全要素生产率
    • ¥15 TI的insta-spin例程
    • ¥15 完成下列问题完成下列问题
    • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
    • ¥15 YoloV5 第三方库的版本对照问题
    • ¥15 请完成下列相关问题!
    • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
    • ¥15 求daily translation(DT)偏差订正方法的代码
    • ¥15 js调用html页面需要隐藏某个按钮