redirect_uri的参数值无效:方案无效:& lt; http: [英] Invalid parameter value for redirect_uri: Invalid scheme: <http:

查看:93
本文介绍了redirect_uri的参数值无效:方案无效:& lt; http:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

晚上好-我正在使用以下YouTube教程命名为"Tutoriel PHP-Importer des contacts Google"来尝试导入Google联系人 https://www.youtube.com/watch?v=ysNVe0TaVFs

Good Evening - I am using the following youtube tutorial named "Tutoriel PHP - Importer des contacts Google" to try and import google contacts https://www.youtube.com/watch?v=ysNVe0TaVFs

当我单击链接以导入google联系人时,出现问题-而不是寻求许可并获取联系人并将其显示在屏幕上,而是出现以下错误:

When I click on the link to import google contacts, instead of asking for permission and getting the contacts and displaying them on screen, there is this problem - I get the following error:

错误:invalid_request

Error: invalid_request

redirect_uri的参数值无效:无效的方案:< http://chi.fis.com/mut_folder/index.php

Invalid parameter value for redirect_uri: Invalid scheme: <http://chi.fis.com/mut_folder/index.php

请告诉我该怎么做才能纠正错误.谢谢.

Please tell me what to do in order to fix the error. Thank you.

这是我的代码:

<?php 
error_reporting(E_ALL);
ini_set("display_errors", 1);

session_start(); ?>
<!DOCTYPE html>
<html class="no-js" lang="en"/>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width" />
    <title>Google Contacts API</title>
</head>

<body>
<h2>Google Contacts API v3.0</h2>
<?php
require_once 'lib/google-api-client/autoload.php';
require 'lib/google-api-client/Config.php';
require 'lib/google-api-client/Google_Client.php';

$client_id = '<aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.bbbbbb.cccccccccccc.com>';
$client_secret = '<jfjdkfj3334FdsfJJF9999JK>';
$redirect_uri = '<http://ccccccccccccccccccc.com/rddddddddddd/index.php>';

$client = new Google_Client();
$client -> setApplicationName('contact');
$client -> setClientid($client_id);
$client -> setClientSecret($client_secret);
$client -> setScopes('https://www.google.com/m8/feeds');
$client -> setRedirectUri($redirect_uri);
$client -> setAccessType('online');

if (isset($_GET['code'])) {
    $client->authenticate();
    $_SESSION['token'] = $client->getAccessToken();
    header('Location: ' . $redirect_uri);
}

if(!isset($_SESSION['token']))
{
    $url = $client->createAuthUrl();
    echo '<a href="' . $url . '">Import Google Contacts</a>';
}else{
        $client->setAccessToken($_SESSION['token']);
        $token = json_decode($_SESSION['token']);
        $token->access_token;
        $curl = curl_init("https://www.google.com/m8/feeds/contacts/default/full?alt=json&max-results=50&access_token=" . $token->access_token);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($curl, CURLOPT_TIMEOUT, 10);
        $contacts_json = curl_exec($curl);
        curl_close($curl);
        $contacts = json_decode($contacts_json, true);
        $return = array();
        foreach($contacts['feed']['entry'] as $contact){
            $return[] = array(
            'name' => $contact['title']['$t'],
            'email' => isset($contact['gd$email'][0]['address']) ? $contact['gd$email'][0]['address'] : false,
            'phone' => isset($contact['gd$phoneNumber'][0]['$t']) ? $contact['gd$phoneNumber'][0]['$t'] :false,
            );
        }
        var_dump($return);
    }       
?>

</body>
</html>

推荐答案

您传递给 setRedirectUri 的URL中包含无效字符.

You have invalid characters in the URL you pass to setRedirectUri.

替换:

$redirect_uri = '<http://ccccccccccccccccccc.com/rddddddddddd/index.php>';

使用

$redirect_uri = 'http://ccccccccccccccccccc.com/rddddddddddd/index.php';

这篇关于redirect_uri的参数值无效:方案无效:&amp; lt; http:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆