Search code examples
iosiphonexcodeios7google-api-objc-client

Content is not allowed in prolog error on google contact api in ios


I want to add iPhone contact in Google contact. I was used Google contact API.but it give me error Content is not allowed in prolog. i searched this error but not succeeded.

i can authenticate Google through web view and get access-token. After that call API my request is http://www.google.com/m8/feeds/contacts/default/full?access_token=ya29.1.AADtN_V0YDqLjA7-GmIRZN6Z_yNdfe3z-AmZMx0-ZPPyAvJFsThMaT1E5aF1Qg

please help me regarding this issue.

method type = post

Content type = application/atom+xml;charset=utf-8

Thanks


Solution

  • if you are json

    application/atom+json;charset=utf-8
    

    if your xml means try this

    $headers = array('Content-Type: application/atom+xml; charset=utf-8',
    'Content-Length: '. strlen($xml),
    'Authorization: GoogleLogin '. trim($authToken)),
    'Connection: close');
    

    For more information:

    or

    check your xml document tag

    <!-- Correct -->
    <?xml version="1.0" encoding="utf-8"?>