Note that there are some explanatory texts on larger screens.

plurals
  1. POGoogle+ API CommentActivity return 400 Error
    primarykey
    data
    text
    <p>I'm having no luck calling the Google+ API for pushing a <a href="https://developers.google.com/+/api/moment-types/comment-activity" rel="nofollow noreferrer">CommentActivity</a> moment. I have been able to push an <a href="https://developers.google.com/+/api/moment-types/add-activity" rel="nofollow noreferrer">AddActivity</a> successfully as well as a <a href="https://developers.google.com/+/api/moment-types/discover-activity" rel="nofollow noreferrer">DiscoverActivity</a>. </p> <p>I read somewhere on the internet whilst searching for a solution that the 400 HTTP Status represents that my user credentials are invalid, but I have been able to post AddActivity &amp; DiscoverActivity after trying CommentActivity and I have tried disconnecting and reconnecting my account and linking the required credentials to no avail.</p> <p>Here's my code to generate the moment, I believe this is the error, and it's probably something to do with the use of a Target and a Result in this moment type (Neither DiscoverActivity nor AddActivity have a Result field). In particular, the Target's and Result's URLs are the same but the Result's has an appended anchor. The documentation implies that this should work fine, however.</p> <pre><code> $moment = new Google_Moment(); $moment-&gt;setType("http://schemas.google.com/CommentActivity"); $target = new Google_ItemScope(); $target-&gt;setUrl(get_permalink($comment-&gt;comment_post_id)); $target-&gt;setType("http://schema.org/Article"); $moment-&gt;setTarget($target); $result = new Google_ItemScope(); $result-&gt;setId("comment-".$comment_id); $result-&gt;setType("http://schema.org/Comment"); $result-&gt;setUrl(get_comment_link($comment_id)); $result-&gt;setText($comment-&gt;comment_content); $moment-&gt;setResult($result); Soci_Base::getSocial("google")-&gt;getUser($user)-&gt;GPlus-&gt;moments-&gt;insert('me', 'vault', $moment); </code></pre> <p>GPlus is a reference to a Google_PlusService object.</p> <p>Here's my exception I receive with stack trace (Pointless parts of the files are omitted, hooks.php and plugin.php are not the Google+ API)</p> <blockquote> <p><strong>Fatal error</strong>: Uncaught exception 'Google_ServiceException' with message 'Error calling POST <a href="https://www.googleapis.com/plus/v1/people/me/moments/vault?key=AIzaSyBa27u5PtBgFHO4SY_Fq9_0sO39pFWrRzE" rel="nofollow noreferrer">https://www.googleapis.com/plus/v1/people/me/moments/vault?key=AIzaSyBa27u5PtBgFHO4SY_Fq9_0sO39pFWrRzE</a>: (400) Invalid Value' in /~/src/io/Google_REST.php:66 Stack trace: #0 /~/G+/src/io/Google_REST.php(36): Google_REST::decodeHttpResponse(Object(Google_HttpRequest)) #1 /~/G+/src/service/Google_ServiceResource.php(186): Google_REST::execute(Object(Google_HttpRequest)) #2 /~/G+/src/contrib/Google_PlusService.php(167): Google_ServiceResource->__call('insert', Array) #3 /~/hooks.php(54): Google_MomentsServiceResource->insert('me', 'vault', Object(Google_Moment)) #4 /~/plugin.php(406): soci_comment('108040') #5 /~ in <b>/~/lib/G+/src/io/Google_REST.php</b> on line <b>66</b><br /></p> </blockquote> <p>I think that's all of the info I have on the matter - I have no idea to get the exact HTTP request the script makes. Thank you in advance for any and all help and for even having a look ^_^</p> <p>Here's the code for the whole login sequence:</p> <pre><code>Soci_Google::addActionRequirement('http://schemas.google.com/AddActivity'); Soci_Google::addActionRequirement('http://schemas.google.com/CommentActivity'); Soci_Google::addActionRequirement('http://schemas.google.com/CreateActivity'); Soci_Google::addActionRequirement('http://schemas.google.com/DiscoverActivity'); </code></pre> <p>Soci_Google::addActionRequirement:</p> <pre><code>public static function addActionRequirement($url) { self::$activities[] = $url; } </code></pre> <p>self::$token is just a reference to a string</p> <pre><code>$ret = new Soci_Google(); self::$users[$id] = $ret; $ret-&gt;setToken(self::$meta-&gt;getMeta($user, self::$token)); return $ret; </code></pre> <p>Soci_Google __construct():</p> <pre><code>public function __construct() { $this-&gt;googleObj = new Google_Client(); $this-&gt;googleObj-&gt;setApplicationName(self::$appName); $this-&gt;googleObj-&gt;setClientId(self::$clientID); $this-&gt;googleObj-&gt;setClientSecret(self::$clientSecret); $this-&gt;googleObj-&gt;setRedirectUri(self::$redirectURI); $this-&gt;googleObj-&gt;setDeveloperKey(self::$devKey); $this-&gt;GPlus = new Google_PlusService($this-&gt;googleObj); $this-&gt;googleObj-&gt;setRequestVisibleActions(self::$activities); } </code></pre> <p>Soci_Goolge setToken</p> <pre><code>$this-&gt;googleObj-&gt;setAccessToken($googleUsrToken); </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
 

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