0

データを含む連絡先を Google 連絡先に追加したいのですが、「リクエストにエラーがありました。それがすべてです。」というエラーが表示されます。

コードは次のとおりです。

<?php
$contact_detail='<?xml version="1.0"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:gd="http://schemas.google.com/g/2005">
    <gd:name>
        <gd:firstName>John</gd:firstName>
        <gd:additionalName> test</gd:additionalName>
        <gd:givenName>Doe</gd:givenName>
    </gd:name>
    <gd:email address="john@doe.com" rel="http://schemas.google.com/g/2005#work"/>
    <gd:email address="john2@doe.com" rel="http://schemas.google.com/g/2005#home"/>
    <gd:organization rel="http://schemas.google.com/g/2005#work">
        <gd:orgName>John Deere</gd:orgName>
        <gd:orgTitle>Owner</gd:orgTitle>
    </gd:organization>
</atom:entry>';
$url="https://www.google.com/m8/feeds/contacts/default/full";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_MUTE, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
curl_setopt($ch, CURLOPT_POSTFIELDS, "$contact_detail");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
print($output);
curl_close($ch);
4

1 に答える 1

0

https://developers.google.com/google-apps/contacts/v2/developers_guide_protocol

このエントリを公開するには、次のように連絡先リストの投稿 URL に送信します。最初に、application/atom+xml コンテンツ タイプを使用して、Atom 要素を新しい POST 要求の本文に配置します。次に、投稿の URL に送信します。たとえば、liz@gmail.com に属する連絡先リストに連絡先を追加するには、新しいエントリを次の URL に投稿します: https://www.google.com/m8/feeds/contacts/liz%40gmail.com/満杯

于 2013-01-16T06:45:36.583 に答える