【问题标题】:Google+ Api not updatingGoogle+ API 未更新
【发布时间】:2018-02-26 05:13:49
【问题描述】:

我的 Google+ Api 有问题。它工作正常,但突然停止从 Google+ 页面检索数据。

这是代码,运行良好,没有任何变化。

 <?php

        $guserid = get_field('google_plus_user_id','option');
        $gplus_api = get_field('google_plus_api_key','option');

       if(empty($guserid))
            $guserid = "***ID***";

        if(empty($gplus_api))
           $gplus_api = "***API***";

    $gactivity_url = "https://www.googleapis.com/plus/v1/people/".$guserid."/activities/public?maxResults=1&key=".$gplus_api;

        $gactivity = json_decode(file_get_contents($gactivity_url));
        $items = $gactivity->items[0];

        $created_time = $items->updated;
        $link         = $items->url;
        $title        = $items->title;

        $attachments  = $items->object->attachments[0];
            $full_picture = $attachments->image->url;
          ?>
<img src="<?php echo $full_picture; ?>" alt="Google+"/>
        <div class="gp_content">
        <div><?php echo $attachments->content ?></div>
        <a target="_blank" href="<?php echo $link; ?>"><?php echo $title; ?> </a>
          <dt> <?php echo date('d/m/Y', strtotime($created_time)); ?> </dt>

我收到以下错误

    Warning: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in C:\Inetpub\vhosts\abc.com\httpdocs\fc\wp-content\themes\abc\social-feeds-tpl.php on line 114

Warning: file_get_contents(): Failed to enable crypto in C:\Inetpub\vhosts\abc.com\httpdocs\fc\wp-content\themes\abc\social-feeds-tpl.php on line 114

Warning: file_get_contents(https://www.googleapis.com/plus/v1/people/USERID/activities/public?maxResults=1&key=APIKEY): failed to open stream: operation failed in C:\Inetpub\vhosts\abc.com\httpdocs\fc\wp-content\themes\abc\social-feeds-tpl.php on line 114

Notice: Trying to get property of non-object in C:\Inetpub\vhosts\abc.com\httpdocs\fc\wp-content\themes\abc\social-feeds-tpl.php on line 115

Notice: Trying to get property of non-object in C:\Inetpub\vhosts\abc.com\httpdocs\fc\wp-content\themes\abc\social-feeds-tpl.php on line 117

Notice: Trying to get property of non-object in C:\Inetpub\vhosts\abc.com\httpdocs\fc\wp-content\themes\abc\social-feeds-tpl.php on line 118

Notice: Trying to get property of non-object in C:\Inetpub\vhosts\abc.com\httpdocs\fc\wp-content\themes\abc\social-feeds-tpl.php on line 119

Notice: Trying to get property of non-object in C:\Inetpub\vhosts\abc.com\httpdocs\fc\wp-content\themes\abc\social-feeds-tpl.php on line 121

Notice: Trying to get property of non-object in C:\Inetpub\vhosts\abc.com\httpdocs\fc\wp-content\themes\abc\social-feeds-tpl.php on line 121

Notice: Trying to get property of non-object in C:\Inetpub\vhosts\abc.com\httpdocs\fc\wp-content\themes\abc\social-feeds-tpl.php on line 122

Notice: Trying to get property of non-object in C:\Inetpub\vhosts\abc.com\httpdocs\fc\wp-content\themes\abc\social-feeds-tpl.php on line 122

Notice: Trying to get property of non-object in C:\Inetpub\vhosts\abc.com\httpdocs\fc\wp-content\themes\abc\social-feeds-tpl.php on line 126

Notice: Trying to get property of non-object in C:\Inetpub\vhosts\abc.com\httpdocs\fc\wp-content\themes\abc\social-feeds-tpl.php on line 126

感谢任何帮助。

【问题讨论】:

  • 谁能帮忙禁用 SSL 认证?

标签: ssl google-api ssl-certificate google-plus


【解决方案1】:

应该这样做:

$context = stream_context_create([
    'ssl' => [
        'verify_peer' => false,
    ]
]);

$data = file_get_contents($gactivity_url, false, $context);

【讨论】:

  • 谢谢@Jesh。如果我想验证 SSL 认证,您能帮我吗?因为不建议禁用 SSL 认证。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-05-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多