我正在寻找一个 PHP 页面来创建一个谷歌用户帐户,Oauth 正在工作,但是我现在处于一个阶段,我必须将一些 JSON 格式的数据发布到谷歌来配置帐户,我完全不知所措我我害怕!
我有一个 PHP 脚本需要在下面的链接中发布信息...
https://developers.google.com/admin-sdk/directory/v1/reference/users/insert
谁能给我一个例子来说明我应该做些什么来实现这一目标?
提前致谢!
更新:
好的,我尝试了以下但没有成功,有人对我做错了什么有任何想法吗?是因为 Google 期望这是 JSON 格式吗?
$first_name = $_POST['first_name'];
$surname = $_POST['surname'];
$managers_email = $_POST['managers-email'];
$department = $_POST['department'];
$month = $_POST['month'];
$day = $_POST['day'];
$year = $_POST['year'];
$laptop = $_POST['laptop'];
$location = $_POST['location'];
$quan = $_POST['quantity'];
$aastra = $_POST['phone'];
$sales = $_POST['sales'];
$salesteam = $_POST['sales.team'];
$sales = $_POST['support'];
$uid = strtolower($first_name.".".$surname);
$email = strtolower($first_name.".".$surname."@wandisco.com");
$full_name = $first_name." ".$surname;
//set up a connection variable for the page you will post data to
$curl_connection = curl_init$first_name = $_POST['first_name'];
'https://www.googleapis.com/admin/directory/v1/users');
//curl basic setup
curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl_connection, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1);
//$_POST variables to pass
$post_items[] = 'primaryEmail='.$email;
$post_items[] = 'name='.$full_name;
$post_items[] = 'name.familyName='.$surname;
$post_items[] = 'name.givenName='.$first_name;
$post_items[] = 'password=9ceptuZQtg2H';;
//format the $post_items into a string
$post_string = implode ('&', $post_items);
//send the $_POST data to the new page
curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string);
$result = curl_exec($curl_connection);
curl_close($curl_connection);