Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to post a post in Blogger using PHP?
    primarykey
    data
    text
    <p>I have trouble in how to post a post in Blogger, according to their <a href="https://developers.google.com/blogger/docs/3.0/using#AddingAPost" rel="nofollow">documentation</a> the query must look like:</p> <pre><code>POST https://www.googleapis.com/blogger/v3/blogs/{blogId}/posts/ Authorization: {OAuth 2.0 token} Content-Type: application/json { "kind": "blogger#post", "blog": { "id": "{blogId}" }, "title": "A new post", "content": "With &lt;b&gt;exciting&lt;/b&gt; content..." } </code></pre> <p>In my case I am always getting '<strong>Invalid Credentials</strong>', but I still can get blog info while I failed to insert a post.</p> <pre><code>Returned response: { "error": { "errors": [ { "domain": "global", "reason": "authError", "message": "Invalid Credentials", "locationType": "header", "location": "Authorization" } ], "code": 401, "message": "Invalid Credentials" } } </code></pre> <p>Code used to insert post:</p> <pre><code>$postTitle = 'post test'; $postContent = 'just another test.'; $url = 'https://www.googleapis.com/blogger/v3/blogs/'.$blogId.'/posts/'; $headerQuery = array(); $headerQuery[] = 'Authorization: '.$accessToken; $headerQuery[] = 'Content-Type: application/json'; $headerQuery[] = ' { "kind": "blogger#post", "blog": {"id": "'.$blogId.'"}, "title": "'.$postTitle.'", "content": "'.$postContent.'" }'; //$headerQuery[] = 'Content-length: '.strlen($headerQuery[2]); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, TRUE); curl_setopt($ch, CURLOPT_HTTPHEADER, $headerQuery); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); $data = curl_exec($ch); echo $data; //echo curl_errno($ch); $response = json_decode($data); echo "url: " . $response-&gt;url."&lt;br /&gt;"; echo "id: " . $response-&gt;id."&lt;br /&gt;"; curl_close($ch); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload