2013-06-04 1 views
2

을 반환합니다. PlusClient 라이브러리의 writeMoment에 대해 이해할 수없는 버그가 있습니다. 연결, 괜찮 PlusShare.Builder 괜찮 대화 형 글을 쓰고 친구를 발견하고 모든 물건이 잘 작동하지만 writeMoment 반환 :PlusClient.writeMoment (순간)은 500 (Android PlusClient API)

protected void onCreate(Bundle savedInstanceState) { 
super.onCreate(savedInstanceState); 
// Build your GPlus Person: 
mPlusClient = new PlusClient.Builder(this, this, this) 
.setVisibleActivities(
    "http://schemas.google.com/AddActivity", 
    "http://schemas.google.com/CommentActivity", 
    "http://schemas.google.com/DiscoverActivity") 
.setScopes(Scopes.PLUS_LOGIN, Scopes.PLUS_PROFILE) 
.build(); 
//Others stuffs 

그리고 :

06-04 14:04:36.869: E/Volley(939): [2914] il.a: Unexpected response code 500 for https://www.googleapis.com/plus/v1/people/me/moments/vault 
06-04 14:04:36.869: D/GooglePlusPlatform(939): Unexpected response code (500) when requesting: writeMoment 
06-04 14:04:36.869: D/GooglePlusPlatform(939): Error response: { 
06-04 14:04:36.869: D/GooglePlusPlatform(939): "error": { 
06-04 14:04:36.869: D/GooglePlusPlatform(939): "code": 500, 
06-04 14:04:36.869: D/GooglePlusPlatform(939): "message": null 
06-04 14:04:36.869: D/GooglePlusPlatform(939): } 
06-04 14:04:36.919: D/SyncManager(25079): failed sync operation **** u0 (com.google), com.google.android.gms.plus.action, USER, earliestRunTime 479744535, SyncResult: stats [ numIoExceptions: 1] 

내 코드는 다음과 같다 .()

void writeMomentInStream() { 
    Person owner = mPlusClient.getCurrentPerson(); 
    ItemScope target = new ItemScope.Builder() 
      // Also, use ItemScope.setId() to create a unique application specific ID for the item you are writing. 
      // It should NOT be set as the Google+ user ID. 
      .setId(new Date().toString()) 
      .setText("text") 
      .setDescription("description") 
      .setThumbnailUrl(owner.getImage().getUrl()) 
      .setType("http://schema.org/Thing") 
      .build(); 
    // Ensure in your new PlusClient.Builder(this, this, this).setVisibleActivities(
    // "http://schemas.google.com/AddActivity", "http://schemas.google.com/ListenActivity").build() 
    // You have define the activity you want to add as your moment type 
    Moment moment = new Moment.Builder() 
     .setType("http://schemas.google.com/AddActivity") 
     .setTarget(target) 
     .build(); 

    if(mPlusClient.isConnected()) { 
     mPlusClient.writeMoment(moment); 
    }else {Log.e(TAG, "writeMomentInStream called !!!!mPlusClient.isConnected()"); 
    } 
    Toast.makeText(fragment.getActivity(), "Moment has been sent", Toast.LENGTH_SHORT).show(); 
} 

답변

0

나는 문제가 ID가 새로운 날짜로 설정되어 있는지 생각 공백을 포함 toString()와 API는 먹지 않습니다라는 방법입니다. 공백을 lodash로 바꾸면 작동합니다. .setId (new Date(). toString()). (/ \ W/gi, "_")를

관련 문제