2016-10-14 4 views
0

CURLOPT_POSTFIELDS google plus..add post에 대한 값을 보냈습니다.내 Google 플러스 활동에 게시물을 만들 수 없습니다.

내가 구글에 ..authentication 토큰을 얻을 수있어 plus..but 내가 구글에 게시물을 추가 플러스 .. 때 나는 그 오류를 얻고있다

{ 
    "error":{ 
     "errors":[ 
     { 
      "domain":"global", 
      "reason":"forbidden", 
      "message":"Forbidden" 
     } 
     ], 
     "code":403, 
     "message":"Forbidden" 
    } 
} 

데이터

{ 
    "object":{ 
     "originalContent":"Happy weekend!" 
    }, 
    "access":{ 
     "items":[ 
     { 
      "type":"domain" 
     } 
     ], 
     "domainRestricted":true 
    } 
} 
보내기

코드 :이 문제에 대한 두 가지 가능한 원인이 있습니다

$url = 'https://www.googleapis.com/plusDomains/v1/people/' . $user_id . '/activities'; 

    $headers = array(

     'Authorization : Bearer ' . $accesstoken, 

     'Content-Type : application/json', 

     'Accept : application/json', 

    ); 

    $post_data = array("object" => array("originalContent" => "Happy weekend!"), "access" => array("items" => array(array("type" => "domain")),"domainRestricted" => true)); 

    //$post_data = array("message" => "Shareing Message to your account will be here"); 


    ///$post_data['newcontent'] = "Post on Google Plus Test By Me"; 

    echo $data_string = json_encode($post_data); 

    $ch = curl_init(); 

    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); 

    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); 

    curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); 

    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 

    curl_setopt($ch, CURLOPT_URL, $url); 

    $file_result = curl_exec($ch); 

    print_r($file_result); 

    curl_close($ch); 
+0

403, 권한이 없습니다. – Danh

답변

0

:

  1. 귀하의 질문에 귀하는 Google+에 게시하려한다고 말합니다. Google+ API은 읽기 전용 인 소셜 미디어 사이트를 Google+에 게시 할 수 없습니다.
  2. 코드가 google + 도메인에 게시하려고합니다. Google+ domains API 사용 이 오류는 인증하려는 사용자가 google plus domains account에 액세스 할 수 없기 때문에 발생합니다. 사용자가 Google Plus 도메인 계정에 올바르게 액세스했는지 다시 확인하십시오. 또한 Google 플러스 도메인 및 Google 플러스 소셜 미디어 사이트에 대해 묻고 있음을 정확하게 반영하도록 질문의 제목과 태그를 수정하십시오.

소셜 미디어 웹 사이트를 Google+에 게시하려고하면 할 수 없기 때문에 지금 중지 할 수 있습니다.