Google+ Api 没有更新
Google+ Api not updating
我的 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
感谢任何帮助。
应该这样做:
$context = stream_context_create([
'ssl' => [
'verify_peer' => false,
]
]);
$data = file_get_contents($gactivity_url, false, $context);
我的 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
感谢任何帮助。
应该这样做:
$context = stream_context_create([
'ssl' => [
'verify_peer' => false,
]
]);
$data = file_get_contents($gactivity_url, false, $context);