@LargeTest public void testShareOpenGraphContentWithBadType() throws Exception { ShareOpenGraphObject ogObject = new ShareOpenGraphObject.Builder() .putString("og:title", "a title") .putString("og:type", TEST_OG_OBJECT_TYPE) .putString("og:description", "a description") .build();
@LargeTest public void testCreateOpenGraphObjectWithBadImageType() throws InterruptedException { //only image urls are accepted for createOpenGraphObject Bitmap image = createTestBitmap(128); SharePhoto photo = new SharePhoto.Builder() .setBitmap(image) .setUserGenerated(true) .build(); ShareOpenGraphObject ogObject = new ShareOpenGraphObject.Builder() .putString("og:title", "a title") .putString("og:type", TEST_OG_OBJECT_TYPE) .putString("og:description", "a description") .putPhoto("og:image", photo) .build(); try { GraphRequest request = ShareGraphRequest.createOpenGraphObject(ogObject); request.executeAndWait(); //should fail because do not accept images without image_url fail(); } catch (Exception e){ if(!(e instanceof FacebookException && e.getMessage().equals("Unable to attach images"))){ fail(); } } }
@Test public void testVideoBuilder() { final ShareOpenGraphObject object = ShareModelTestUtility.getOpenGraphObjectBuilder().build(); assertEquals( ShareModelTestUtility.OPEN_GRAPH_BOOLEAN_VALUE,
@LargeTest public void testShareOpenGraphContent() throws Exception { ShareOpenGraphObject ogObject = new ShareOpenGraphObject.Builder() .putString("og:title", "a title") .putString("og:type", TEST_OG_OBJECT_TYPE) .putString("og:description", "a description") .build();
@LargeTest public void testCreateOpenGraphObject() throws InterruptedException { Uri testImage = Uri.parse("http://i.imgur.com/Diyvl7q.jpg"); SharePhoto photo = new SharePhoto.Builder() .setImageUrl(testImage) .setUserGenerated(true) .build(); ShareOpenGraphObject ogObject = new ShareOpenGraphObject.Builder() .putString("og:title", "a title") .putString("og:type", TEST_OG_OBJECT_TYPE) .putString("og:description", "a description") .putPhoto("og:image", photo) .build(); try { GraphRequest request = ShareGraphRequest.createOpenGraphObject(ogObject); GraphResponse response = request.executeAndWait(); assertNotNull(response); assertNull(response.getError()); JSONObject graphResult = response.getJSONObject(); assertNotNull(graphResult); assertNotNull(graphResult.optString("id")); assertNotNull(response.getRawResponse()); } catch (Exception e){ fail(); } }
private ShareOpenGraphAction getAction() { return new ShareOpenGraphAction.Builder() .putString(TYPE_KEY, "myActionType") .putObject( "myObject", new ShareOpenGraphObject.Builder() .putString("myString", "value") .putInt("myInt", 42) .putBoolean("myBoolean", true) .putStringArrayList( "myStringArray", createArrayList( "string1", "string2", "string3") ) .putObject( "myObject", new ShareOpenGraphObject.Builder() .putDouble("myPi", 3.14) .build() ) .build()).build(); }
@Override protected void populateOpenGraphAction(ShareOpenGraphAction.Builder actionBuilder) { if (foodChoice != null && foodChoice.length() > 0) { if (foodChoiceUrl != null && foodChoiceUrl.length() > 0) { actionBuilder.putString("meal", foodChoiceUrl); } else { ShareOpenGraphObject mealObject = new ShareOpenGraphObject.Builder() .putString("og:type", MEAL_OBJECT_TYPE) .putString("og:title", foodChoice) .build(); actionBuilder.putObject("meal", mealObject); } } }
public static ShareOpenGraphObject.Builder getOpenGraphObjectBuilder() { return prepareOpenGraphValueContainerBuilder(new ShareOpenGraphObject.Builder()); }
private ShareOpenGraphObject createGameObject(final SharePhoto gesturePhoto) { return new ShareOpenGraphObject.Builder() .putString("og:title", DEFAULT_GAME_OBJECT_TITLE) .putString("og:type", "fb_sample_rps:game") .putString("fb_sample_rps:player_gesture", CommonObjects.BUILT_IN_OPEN_GRAPH_OBJECTS[playerChoice]) .putString("fb_sample_rps:opponent_gesture", CommonObjects.BUILT_IN_OPEN_GRAPH_OBJECTS[computerChoice]) .putString("fb_sample_rps:result", getString(result.getResultStringId())) .putPhotoArrayList("og:image", new ArrayList<SharePhoto>() {{ add(gesturePhoto); }}) .build(); }
public Builder() { super(); this.putBoolean(NativeProtocol.OPEN_GRAPH_CREATE_OBJECT_KEY, true); }