2014-02-08 3 views
2

Facebook에 기록을 공유하고 싶은 앱이 있습니다. 내 신청서에 웹이 없습니다. 나는 단지 제목과 설명으로 이미지를 공유하기를 원하며 공유 사이트를 클릭 할 때 앱을 다운로드하기 위해 Google Play로 리디렉션하거나 페이스 북 앱 페이지로 리디렉션 할 가능성이있는 경우에만 가능합니다.opengraphobject.setproperty ("og : url")가 설정된 경우에만 Facebook SDK가 사용자를위한 미리보기를 생성하지 못했습니다.

나는 대부분의 페이스 북 샘플에서 답을 찾는데, 여기 저기에 내가 잘못하고있는 것이있다. 모든 Facebook 앱 구성을 만들었습니다. 키 해시 등 ... 나는 Publicar a Lugar라고 불리는 공개 그래프로 히스토리를 생성한다. Action = "Publicar"Object = "루가".

내가 스마트 폰에 두 개의 다른 오류 디버깅을

private void OpenShareDialog(){ 
    Session session = Session.getActiveSession(); 

    if (session != null) { 
     // Check for publish permissions 
     List<String> permissions = session.getPermissions(); 
     if (!isSubsetOf(PERMISSIONS, permissions)) { 
      pendingPublishReauthorization = true; 
      Session.NewPermissionsRequest newPermissionsRequest = new Session.NewPermissionsRequest(this, PERMISSIONS); 
      session.requestNewPublishPermissions(newPermissionsRequest); 
      return; 
     } 

    } 

    OpenGraphObject oplugar = OpenGraphObject.Factory.createForPost("namespace:lugar"); 
    oplugar.setProperty("og:type","namespace:lugar"); 
    oplugar.setProperty("og:title", LugarCargado.getNombre()); 
    //oplugar.setProperty("og:image", "http://estaticos.sport.es/resources/jpg/2/1/1391546433412.jpg"); 
    //oplugar.setProperty("og:url", "http://www.udg.edu/"); 
    oplugar.setProperty("og:description", LugarCargado.getDescripcion()); 

    //Bitmap bitmap;  
    //List<Bitmap> bitmaps = new ArrayList<Bitmap>(); 
    //bitmap = BitmapFactory.decodeResource(this.getResources(), R.drawable.icoappfacebook2); 
    //Log.i(TAG, "Imagen: Height:"+bitmap.getHeight()+ " Width:"+ bitmap.getWidth()); 
    //bitmaps.add(bitmap); 

    //OpenGraphAction action = GraphObject.Factory.create(OpenGraphAction.class); 
    OpenGraphAction action = OpenGraphAction.Factory.createForPost("namespace:publicar"); 
    action.setProperty("lugar", oplugar); 
    action.setType("namespace:publicar"); 
    action.setProperty("previewPropertyName", oplugar); 

    FacebookDialog shareDialog = new FacebookDialog.OpenGraphActionDialogBuilder(this, action, "lugar") 
      //.setImageAttachmentsForObject("lugar", bitmaps, true) 
      //.setImageAttachmentsForAction(bitmaps,true); 
      .build(); 

    uiHelper.trackPendingDialogCall(shareDialog.present()); 
} 

이 코드를했습니다 :

1 나는이 라인 중 하나의 주석을 해제하면

//oplugar.setProperty("og:image", "http://estaticos.sport.es/resources/jpg/2/1/1391546433412.jpg"); 
//oplugar.setProperty("og:url", "http://www.udg.edu/"); 

나는 오류가 그 "com.facebook.FacebookException : 사용자에 대한 미리보기를 생성하는 데 실패했습니다." URL을 퍼팅 할 수 없습니다.

2 맞춤 이미지를 추가하고 싶습니다. 09 :이 코드를

//Bitmap bitmap;  
    //List<Bitmap> bitmaps = new ArrayList<Bitmap>(); 
    //bitmap = BitmapFactory.decodeResource(this.getResources(), R.drawable.icoappfacebook2); 
    //Log.i(TAG, "Imagen: Height:"+bitmap.getHeight()+ " Width:"+ bitmap.getWidth()); 
    //bitmaps.add(bitmap); 

//.setImageAttachmentsForAction(bitmaps,true); 

주석을 제거하면 나는 ... 검은 창 무언가를 다시 시작해야 할 것 같다

02-08 (15)이 46.500 : W를/GAV3 (15911) : 스레드 [GAThread, 5, main] : 서비스를 사용할 수 없습니다 (코드 = 1), 재 시도합니다. 02-08 15 : 09 : 46.500 : I/GAV3 (15911) : 실 [GAThread, 5, main] : 아니요, 캠페인 데이터가 있습니다. 02-08 15 : 09 : 48.482 : D/AbsListView (15911) : unregisterIRListener()가 02-08 15 : 09 : 48.982 : 으로 호출 됨 D/AbsListView (15911) : onVisibilityChanged()가 호출 됨, 가시성 : 4 02 -08 15 : 09 : 48.982 : D/AbsListView (15911) : unregisterIRListener (Reconnect, 5, main) : 서비스를 사용할 수 없습니다. 02-08 15 : 09 : 51.525 : W/GAV3 (15911) : 스레드가 입니다. (코드 = 1). 02-08 15 : 09 : 53.778 : D/AbsListView (16092) : MotionRecognitionManager 얻기 02-08 15 : 09 : 53.778 : D/AbsListView (16092) : onVisibilityChanged()가 호출 됨 visibility : 8 02-08 15 : 0 : 08 : 15 : 09 : 53.788 : D/ProgressBar (16092) : setProgress = ProgressBar (16092) : mProgress = 0mIndeterminate = false, mMin = 0, mMax = 10000 02-08 15:09 : ProgressBar (16092) : setProgress = 0, fromUser = 53828 : D/AbsListView (16092) : onVisibilityChanged()가 호출되면 표시 여부 : 4 02-08 15 : 09 : 53.828 : D/AbsListView (16092) : unregisterIRListener()가 012-02-08 15:09 : 53.838 : D/AbsListView (16092) : unregisterIRListener()가 02-08 15:09에 호출되었습니다. D/AbsListView (16092) : onVisibilityChanged()가 호출되면 가시성 : 0 02-08 15 : 09 : 53.838 : D/53848 : D/libEGL (16092) :로드 됨 /system/lib/egl/libEGL_adreno200.so 02-08 15 : 09 : 53.858 : D/libEGL (16092) :로드 됨 /system/lib/egl/libGLESv1_CM_adreno200.so 02-08 15:09:53.858 : D/libEGL (16,092)을 09 : 53.858 15 /system/lib/egl/libGLESv2_adreno200.so 02-08 로드 I/Adreno200 EGL-(16,092) : 1.4 EGL QUALCOMM 빌드 :

AYELDER_AU_LINUX_ANDROID_JB_2.5.5.04.02.02.092.023 + PATCH [ES] _msm8960_JB_2.5.5_CL3556704_release_ENGG (CL3556704) 02-08 15 : 09 : 53.858 : I/Adreno200-EGL (16092) : 빌드 날짜 : 05/17/13 금 02/08 15 : 09 : 53.858 : I/Adreno200-EGL (16092) : 로컬 지점 : 02-08 15 : 09 : 53.858 : I/Adreno200-EGL (16092) : 원격 지점 : quic/jb_2.5.5 02 -08 15 : 09 : 53.858 : I/Adreno200-EGL (16092) : 로컬 패치 : 34c9e193f12610d3e68dabd6198d2c4bfbc66974 RB : 마스터 업데이트

에서의 hw_image 15,

소인 rb_texture_update_aliased 02-08 15 : 09 : 53.858 : I/Adreno200 EGL-(16,092) 재구성 점 : AU_LINUX_ANDROID_JB_2.5.5.04.02.02.092.023 + + 01d3c78

e6f0547 + D/ProgressBar (16092) : updateDrawableBounds : left = 0 02-08 15 : 09 : 53.878 : D/OpenGLRenderer (16092) : 디버그 모드 사용 0 02-08 15 : 09 : 53.878 : 15 : 09 : 53.878 : D/ProgressBar (16092) : updateDrawableBounds : 위쪽 = 0 02-08 15 : 09 : 53.878 : D/ProgressBar (16092) : updateDrawableBounds : 오른쪽 = 72 02-08 15 : 09 : 53.878 : D/ProgressBar (16092) : updateDrawableBounds : bottom = 72 02-08 15 : 09 : 54.058 : I/System (16092) :로드 된 시간대 217ms (ICU에서 205ms)에 대한 이름 02-08 15 : 09 : 54.088 : D/AbsListView (16092) : onVisibilityChanged()가 호출되면 가시성 : 0 02 D/AbsListView (16092) : 02-08 15 : 09 : 54.168 : D/AbsListView (16092) : unregisterIRListener()를 호출했습니다. 02-08 15:09 : 54/08 : 15 : 09 : 54.188 : E/ViewRootImpl (16092) : sendUserActionEvent() mView == null 02-08 15 : 09 : 54.268 : D/AbsListView (16092) : unregisterIRListener/AbsListView (16092) : unregisterIRListener() 02-08 15 : 09 : 58.833 : W/GAV3 (16092) : 스레드 [GAThread, 5, main] : 서비스를 사용할 수 없으면 (코드 = 1) 다시 시도합니다. 02-08 15 : 09 : 58.833 : I/GAV3 (16092) : 실 [GAThread, 5, main] : 캠페인 데이터가 없습니다. 02-08 15 : 10 : 03.838 : W/GAV3 (16092) : 스레드 [Service Reconnect, 5, main] : 로컬 저장소를 사용하는 서비스 을 사용할 수 없습니다 (코드 = 1). 02-08 15 : 10 : 10.565 : D/AbsListView (16,092) unregisterIRListener()는

이라는 이전의 작업을 표시한다.

위의 코드를 사용하면 sharedialog에서 나에게 페이스 북 대화 상자를 보여주고 공유 할 수 있습니다. 하지만 링크가없고 내 이미지가 없습니다.

도와 주시겠습니까? 나는 많은 다른 것을 시도했다!

내 스마트 폰입니까? 페이스 북 버전?

사용자 (사용자 용) 이미지를 공유 대화 상자의 설명과 공유하기위한 간단한 샘플이 있습니까?

영어로 죄송합니다.

답변

1

웹 구성 요소가없는 경우 og 객체에 url을 설정하지 마십시오. 당신이 URL을 설정하면 페이스 북은 그 URL을 긁어 내려고 시도하고, 거기에서 긁어 낸 OG 메타 데이터가 당신이 제공 한 것과 일치하지 않으면 실패하게됩니다.

현재 OG 작업에 비트 맵을 추가하려면 매니페스트에 NativeAppCallContentProvider도 추가해야합니다. 여기에있는 문서를보십시오 : https://developers.facebook.com/docs/reference/android/current/class/NativeAppCallContentProvider/ 이것은 페이스 북의 앱이 여러분이 보내려는 비트 맵을 실제로 얻을 수있는 방법입니다.

마지막으로 sdk와 함께 제공되는 Scrumptious 샘플 앱을 살펴보십시오. 이미지 첨부 파일과 함께 새로운 OG 객체를 만드는 옵션 ("로그인 건너 뛰기"의 경우)이 있습니다.

+0

URL에 좋습니다. 하지만 내 매니페스트에 NativeAppCallContentProvider가 있습니다. 그리고 나는 Scrumptious 샘플을 실행하려고하는데 미리보기를 만들어야 할 때 실패합니다. 그리고 "사용자를위한 미리보기를 생성하지 못했습니다"라는 오류가 나타납니다. 이것은 다른 휴대 전화 및 코드와도 발생합니다. 미리보기가 잠시 나타나고이 메시지가 사라집니다. 샘플에서는 로그인하지 않고 사진을 찍은 개미 만 먹는 것을 선택합니다. – jsalva

+0

사용중인 SDK 및 Facebook 응용 프로그램의 버전은 무엇입니까? –

+0

sdk 3.6 및 안드로이드에서 마지막 페이 스북 업데이트. – jsalva

0

이 코드를 사용하면 작동하지 않으며 "미리보기를 생성하지 못했습니다." 하지만이 코드는 내가 원하는 것과 다른 방식으로 작동합니다. 이 코드는 OGActiondialog를 엽니 다.하지만 공유 할 때 게시물은 피드에 나타나지 않고 액티비티 레지스트리에 나타나지 않지만 "normal"sharelink와 같은 이름이나 설명이 아닌 사진 만 나타납니다 (왼쪽의 작은 사진과 titol 및 오른쪽의 설명).

가능합니까?

private void OpenShareDialog2(){ 

    if (canPresentOGShareDialog) { 
     Session session = Session.getActiveSession(); 

     if (session != null) { 
      // Check for publish permissions 
      List<String> permissions = session.getPermissions(); 
      if (!isSubsetOf(PERMISSIONS, permissions)) { 
       pendingPublishReauthorization = true; 
       Session.NewPermissionsRequest newPermissionsRequest = new Session.NewPermissionsRequest(this, PERMISSIONS); 
       session.requestNewPublishPermissions(newPermissionsRequest); 
       Log.d(TAG, "Permisos pedidos"); 
       return; 
      } 

     } 

     OpenGraphObject oplugar = OpenGraphObject.Factory.createForPost("namespace:lugar"); 
     oplugar.setProperty("og:type","namespace:lugar"); 
     oplugar.setProperty("og:title", LugarCargado.getNombre()); 
     oplugar.setProperty("og:description", LugarCargado.getDescripcion()); 



     //OpenGraphAction action = GraphObject.Factory.create(OpenGraphAction.class); 
     OpenGraphAction action = OpenGraphAction.Factory.createForPost("namespace:publicar"); 
     action.setProperty("lugar", oplugar); 
     action.setType("namespace:publicar"); 
     //action.setProperty("previewPropertyName", "lugar"); 
     //action.setProperty("fb:explicitly_shared", true); 
     //action.setExplicitlyShared(true); 

     boolean userGenerated = false; 
     if (urifoto != null) { 
      String photoUriString = urifoto.toString(); 
      Pair<File, Integer> fileAndMinDimemsion = getImageFileAndMinDimension(); 
      userGenerated = fileAndMinDimemsion.second >= USER_GENERATED_MIN_SIZE; 

      // If we have a content: URI, we can just use that URI, otherwise we'll need to add it as an attachment. 
      if (fileAndMinDimemsion != null && urifoto.getScheme().startsWith("content")) { 
       action.setImage(getImageListForAction(photoUriString, userGenerated)); 
      } 
     } 

     FacebookDialog.OpenGraphActionDialogBuilder builder = new FacebookDialog.OpenGraphActionDialogBuilder(this, action, "lugar"); 
       //.setFragment(SelectionFragment.this); 

     if (urifoto != null && !urifoto.getScheme().startsWith("content")) { 
      builder.setImageAttachmentFilesForAction(Arrays.asList(new File(urifoto.getPath())), userGenerated); 
     } 

     uiHelper.trackPendingDialogCall(builder.build().present()); 
    } 
} 

private Pair<File, Integer> getImageFileAndMinDimension() { 
    File photoFile = null; 
    String photoUriString = urifoto.toString(); 
    if (photoUriString.startsWith("file://")) { 
     photoFile = new File(urifoto.getPath()); 
    } else if (photoUriString.startsWith("content://")) { 
     String [] filePath = { MediaStore.Images.Media.DATA }; 
     Cursor cursor = this.getContentResolver().query(urifoto, filePath, null, null, null); 
     if (cursor != null) { 
      cursor.moveToFirst(); 
      int columnIndex = cursor.getColumnIndex(filePath[0]); 
      String filename = cursor.getString(columnIndex); 
      cursor.close(); 

      photoFile = new File(filename); 
     } 
    } 

    if (photoFile != null) { 
     InputStream is = null; 
     try { 
      is = new FileInputStream(photoFile); 

      // We only want to get the bounds of the image, rather than load the whole thing. 
      BitmapFactory.Options options = new BitmapFactory.Options(); 
      options.inJustDecodeBounds = true; 
      BitmapFactory.decodeStream(is, null, options); 

      return new Pair<File, Integer>(photoFile, Math.min(options.outWidth, options.outHeight)); 
     } catch (Exception e) { 
      return null; 
     } finally { 
      Utility.closeQuietly(is); 
     } 
    } 
    return null; 
} 

나는 맛있는 샘플에서 다소 차이가납니다!

관련 문제