在ShareDialog中共享打开的图形故事时,无法为用户生成预览

时间:2015-05-20 20:48:21

标签: android facebook facebook-graph-api facebook-sdk-4.0

我使用开放图形故事将新的Facebook SDK实现到我的应用程序中。过程:

  1. “Facebook上的共享按钮
  2. ”对话框出现
  3. 用户点击“在Facebook上分享”按钮,打开“共享对话框”
  4. 打开图表故事出现在对话框中,用户点击右上角的“发布”按钮
  5. 错误: 有时(大约1/6)在共享对话框启动后的第2步之后,它会随着错误而消失

    Error Failed to generate preview for user.
    

    打开图表:

    final String fbNamespace = "myns";
    
            // Create an object
            ShareOpenGraphObject object = new ShareOpenGraphObject.Builder()
                    .putString("og:type", fbNamespace + ":badge")
                    .putString("og:description", "Some description")
                    .putString("og:title", "I've just unlocked a new badge!")
                    .putString("og:url", "http://website.net")
                    .putString("og:image", url)
                    .build();
    
            // Create an action
            ShareOpenGraphAction action = new ShareOpenGraphAction.Builder()
                    .setActionType(fbNamespace + ":unlock")
                    .putObject("badge", object)
                    .build();
    
            // Create the content
            ShareOpenGraphContent content = new ShareOpenGraphContent.Builder()
                    .setPreviewPropertyName("badge")
                    .setAction(action)
                    .build();
    
            ShareDialog.show(MainActivity.this, content);
    

    回调:

    shareDialog = new ShareDialog(this);
            shareDialog.registerCallback(mCallbackManager, new FacebookCallback<Sharer.Result>() {
                @Override
                public void onSuccess(Sharer.Result result) {
                    Log.i("Share", "Success");
                }
    
                @Override
                public void onCancel() {
                    Log.i("Share", "Cancel");
                }
    
                @Override
                public void onError(FacebookException error) {
                    Log.i("Share", "Error" + error.toString()); //Failed to generate preview for user
                }
            });
    

    同样奇怪的是,当ShareDialog与预设图像,标题和描述一起显示时,故事出现大约需要3秒钟。 (这种情况每次都会发生)

    注意:还有其他问题正在寻找相同错误消息的解决方案,但在这些情况下,对话框在显示后总是会消失。

1 个答案:

答案 0 :(得分:0)

在代码中添加命名空间:

<?php $user_query=mysql_query("select * from users")or die(mysql_error());
                                while($row=mysql_fetch_array($user_query)){
                                $id=$row['user_id']; ?>
                                 <tr class="del<?php echo $id ?>">
                                <td><?php echo $row['username']; ?></td> 
                                <td><?php echo $row['password']; ?></td> 
                                <td><?php echo $row['givenname']; ?></td> 
                                <td><?php echo $row['surname']; ?></td> 
                                <td width="100">
                                    <a rel="tooltip"  title="Delete" id="<?php echo $id; ?>"  href="#delete_user<?php echo $id; ?>" data-toggle="modal"  class="btn btn-danger"><i class="icon-trash icon-large"></i></a>
                                    <?php include('delete_user_modal.php'); ?>
                                    <a rel="tooltip"  title="Edit" id="e<?php echo $id; ?>" href="#edit<?php echo $id; ?>" data-toggle="modal" class="btn btn-success"><i class="icon-pencil icon-large"></i></a>
                                    <?php include('modal_edit_user.php'); ?>
                                </td>
                                <?php include('toolttip_edit_delete.php'); ?>