проблема поменять контакт с гугл контактами api - PullRequest
1 голос
/ 27 мая 2019

Я пытаюсь изменить контакт Google через PHP, но на каждый запрос сервер Google не отвечает мне.Если я пытаюсь опубликовать сервер Google в NULL, я получаю недопустимый XML, поэтому я считаю, что запрос PUT правильный.Может ли кто-нибудь помочь мне с некоторыми примерами?Это код в PHP

<code>$access = 'xxx';
$user_email = urlencode('xxx@xxx');
$id_contatto = 'xxx';

$contactXML = '
    <entry gd:etag="*">
    <id>http://www.google.com/m8/feeds/contacts/'.$user_email.'/base/'.$id_contatto.'</id>
    <updated>2019-05-27T17:07:02.303Z</updated>
    <atom:category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/contact/2008#contact"/>
    <gd:name>
        <gd:givenName>Test</gd:givenName>
        <gd:familyName>Test</gd:familyName>
        <gd:fullName>Test Test</gd:fullName>
    </gd:name>
    <content type="text">Notes</content>
    <link rel="http://schemas.google.com/contacts/2008/rel#photo" type="image/*" href="https://www.google.com/m8/feeds/photos/media/'.$user_email.'/'.$id_contatto.'"/>
    <link rel="self" type="application/atom+xml" href="https://www.google.com/m8/feeds/contacts/'.$user_email.'/full/'.$id_contatto.'"/>
    <link rel="edit" type="application/atom+xml" href="https://www.google.com/m8/feeds/contacts/'.$user_email.'/full/'.$id_contatto.'"/>
    <gd:phoneNumber rel="http://schemas.google.com/g/2005#other" primary="true">456-123-2133</gd:phoneNumber>
    <gd:extendedProperty name="pet" value="hamster"/>
    <gd:groupMembershipInfo deleted="false" href="http://www.google.com/m8/feeds/groups/'.$user_email.'/base/6"/>
    </entry>
    
';$ headers = array ('If-Match: *', 'Gdata-version: 3.0', 'Content-type: application / atom + xml',);$ contactQuery = 'https://www.google.com/m8/feeds/contacts/default/full/'.$id_contatto.'?access_token='.$access; $ ch = curl_init ();curl_setopt ($ ch, CURLOPT_URL, $ contactQuery);curl_setopt ($ ch, CURLOPT_CUSTOMREQUEST, "PUT");curl_setopt ($ ch, CURLOPT_PUT, true);curl_setopt ($ ch, CURLOPT_HTTPHEADER, $ заголовки);curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, true);curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ contactXML);curl_setopt ($ ch, CURLOPT_SSL_VERIFYPEER, false);curl_setopt ($ ch, CURLOPT_SSL_VERIFYHOST, false);curl_setopt ($ ch, CURLOPT_CONNECTTIMEOUT, 10);curl_setopt ($ ch, CURLOPT_TIMEOUT, 10);curl_setopt ($ ch, CURLOPT_FAILONERROR, true);$ result = curl_exec ($ ch);if (curl_errno ($ ch)) {$ result = curl_error ($ ch);} var_dump ($ result);

Это результат var_dump после тайм-аута:

string (0) ""

...