PlusClient を使用して、Google+ ユーザーのプロフィールで「瞬間」を使用してロケーション チェックインを書き込もうとしています。これは私がクライアントを初期化する方法です:
mPlusClient = new PlusClient.Builder(this, this, this)
.setVisibleActivities("http://schemas.google.com/AddActivity", "http://schemas.google.com/CheckInActivity")
.setScopes(Scopes.PLUS_LOGIN, Scopes.PLUS_PROFILE).build();
onConnected は次のとおりです。
public void onConnected() {
//Log.d(tag,"onConnected()...");
googlePlusUserEmail = mPlusClient.getAccountName();
Log.d(tag, "googlePlusUserEmail = " + googlePlusUserEmail);
}
「mPlusClient.connect();」を呼び出した後 接続は正常に行われます。正常に機能する +1 ボタンがあり、PlusShare を使用してユーザーのプロフィールに投稿することもできました。
String mapLing = "https://maps.google.com/maps?q=" + myLatitude + "," + myLongitude + "&hl=en";
String description = "Hello!";
Intent shareIntent = new PlusShare.Builder()
.setType("text/plain")
.setText(description)
.setContentUrl(Uri.parse(mapLing))
.getIntent();
startActivityForResult(shareIntent, 0);
ただし、正しく理解していれば、PluShare で画像を「添付」することはできないため、次のように Moments を使用しようとしました。
String mapLing = "https://maps.google.com/maps?q=" + myLatitude + "," + myLongitude + "&hl=en";
String description = "Hello!";
//build the item scope
ItemScope checkInLocation = new ItemScope.Builder()
.setId(googlePlusUserId) //do I need it?
.setType("http://schema.org/Place") //tried also with "Thing" instead of Place, but no luck
.setName(mOverlays.get(index).getSnippet() + " - " + mOverlays.get(index).getTitle())
.setUrl(mapLing)
.setImage("http://www.mysite.com/images/icon.png")
.setDescription(description)
.build();
Moment moment = new Moment.Builder()
.setType("http://schemas.google.com/CheckInActivity")
.setTarget(checkInLocation).build();
if (mPlusClient.isConnected()) {
Log.d(tag, "writeMoment...");
mPlusClient.writeMoment(moment);
}
この回答を確認した後、GooglePlatform の詳細デバッグを有効にしました。
adb shell setprop log.tag.GooglePlusPlatform VERBOSE
残念ながら、その瞬間を書き込もうとすると、次のログが返されます。
05-22 01:08:01.908: E/Volley(3611): [29] il.a: Unexpected response code 400 for https://www.googleapis.com/plus/v1/people/me/moments/vault
05-22 01:08:01.918: D/GooglePlusPlatform(3611): Unexpected response code (400) when requesting: writeMoment
05-22 01:08:01.918: D/GooglePlusPlatform(3611): Error response: {
05-22 01:08:01.918: D/GooglePlusPlatform(3611): "error": {
05-22 01:08:01.918: D/GooglePlusPlatform(3611): "errors": [
05-22 01:08:01.918: D/GooglePlusPlatform(3611): {
05-22 01:08:01.918: D/GooglePlusPlatform(3611): "domain": "global",
05-22 01:08:01.918: D/GooglePlusPlatform(3611): "reason": "invalid",
05-22 01:08:01.918: D/GooglePlusPlatform(3611): "message": "Invalid Value"
05-22 01:08:01.918: D/GooglePlusPlatform(3611): }
05-22 01:08:01.918: D/GooglePlusPlatform(3611): ],
05-22 01:08:01.918: D/GooglePlusPlatform(3611): "code": 400,
05-22 01:08:01.918: D/GooglePlusPlatform(3611): "message": "Invalid Value"
05-22 01:08:01.918: D/GooglePlusPlatform(3611): }
05-22 01:08:01.918: D/GooglePlusPlatform(3611): }
この回答からもわかるように、+1 および PlusShare 機能を正常に使用できるため、資格情報の問題ではないはずです。Google のドキュメントhere、特に CheckInActivity hereも調べましたが、まだ運がありません。応答が 400 である理由について誰かが提案できれば、それは素晴らしいことです。
EDIT1 :以下のScarygamiとLeeの提案の後、次のコードを使用して最も単純な瞬間を追加しようとしました:
ItemScope checkInLocation = new ItemScope.Builder()
.setId("1234545")
.setName("MyName")
//.setUrl(mapLing) //link removed
.setImage("http://www.mysite.com/images/icon.png")
.setDescription("MyDescription")
.setType("http://schema.org/Thing")
.build();
Moment moment = new Moment.Builder()
.setType("http://schemas.google.com/AddActivity")
.setTarget(checkInLocation).build();
if (mPlusClient.isConnected()) {
Log.d(tag, "writeMoment...");
mPlusClient.writeMoment(moment);
Log.d(tag, "moment.getResult() = " + moment.getResult());
}
良いニュースは、400 エラー応答コードがなくなったことです:-)、しかし、私のプロファイルには何も表示されません:-(。私はそれに取り組み、すぐに更新します...