12

我想知道如何从Android应用向我所有的Facebook朋友发送应用请求。我试图在图形API。但是,无法完成。使用Android中的'请求对话框'向Facebook中的所有朋友发送应用请求

https://graph.facebook.com/apprequests?ids=friend1,friend2&message='Hi'&method=post&access_token=ACCESS_TOKEN 

我知道这是一个重复的问题。但是,还没有找到答案。 我在上面的API中收到这个错误。

"All users in param ids must have accepted TOS." 

我希望有一种方法可以通过点击向移动设备上的所有朋友发送应用请求。请分享。

+0

你有应用程序请求的类型要张贴在朋友的墙上,任何PIC或样品。 –

回答

0

你在developer.facebook.com上看过“Hackbook”的演示吗?

你可以参考HACKBOOK APP REQUEST FROM HERE.

可以实现通过下面的代码来发布应用请求您ONLY ONE朋友。

代码:

Bundle params = new Bundle(); 

      JSONObject attachment = new JSONObject(); 
      JSONObject properties = new JSONObject(); 
      JSONObject prop1 = new JSONObject(); 
      JSONObject prop2 = new JSONObject(); 
      JSONObject media = new JSONObject(); 
      JSONStringer actions = null; 
      try { 
       attachment.put("name", "YOUR_APP"); 
       attachment.put("href", "http://www.google.com/"); 
       attachment.put("description", "ANY_TEXT"); 
       media.put("type", "image"); 
       media.put("src", "IMAGE_LINK"); 
       media.put("href", "http://www.google.com/"); 
       attachment.put("media", new JSONArray().put(media)); 
       prop1.put("text", "www.google.com"); 
       prop1.put("href", "http://www.google.com"); 
       properties.put("Visit our website to download the app", prop1); 
       /* prop2.put("href", "http://www.google.com"); 
       properties.put("iTunes Link  ", prop2);*/ 
       attachment.put("properties", properties); 
       Log.d("FACEBOOK", attachment.toString()); 

       actions = new JSONStringer().object() 
          .key("name").value("APP_NAME") 
          .key("link").value("http://www.google.com/").endObject(); 

      } catch (JSONException e) { 
       e.printStackTrace(); 
      } 

      System.out.println("ACTIONS STRING: "+actions.toString()); 
      System.out.println("ATTACHMENT STRING: "+attachment.toString()); 

      params.putString("actions", actions.toString()); 
      params.putString("attachment", attachment.toString()); // Original 
      params.putString("to", "YOUR_FRIEND_FACEBOOK_ID"); 
      Utility.mFacebook.dialog(getParent(), "stream.publish", params,new PostDialogListener()); 



public class PostDialogListener extends BaseDialogListener { 
    @Override 
    public void onComplete(Bundle values) { 
     final String postId = values.getString("post_id"); 
     if (postId != null) { 
      Toast.makeText(getApplicationContext(), ""+getResources().getString(R.string.facebook_response_msg_posted), Toast.LENGTH_SHORT).show(); 
     } else { 
      Toast.makeText(getApplicationContext(), ""+getResources().getString(R.string.facebook_response_msg_not_posted), Toast.LENGTH_SHORT).show(); 
     } 
    } 
} 

上面的代码,如果你想发布Apprequest仅在一个朋友的墙壁运行完美。如果你想发布所有内容,那么你必须制作asynckTask,它为所有朋友发布并在所有墙上发布应用请求。

希望你明白了。

更新

这里是做了同样的工作,以请求发送给所有的Facebook朋友在PHP中的链接。 链接是:HERE

而这里很明显地解释说,它是通过脸书向朋友发送请求到更多然后15-20个朋友。链接如下:HERE

现在,您只有一个选择:在AsyncTask中使用上面的代码将朋友请求发送给所有朋友一个接一个。

希望你现在能更好地理解。

请评论你到现在为止的成就。

谢谢。

+0

它将在朋友墙上发布关于该应用的信息。 – Gugan

+1

应用程序请求不得转到墙上,它必须转到用户通知或应用程序请求列表 – Gugan

+0

它将在通知上。 –

5

您收到的错误消息(“参数ID中的所有用户都必须接受TOS”)是因为您尝试将应用程序生成的请求发送给未连接到应用程序的用户。

查看developer docs here

与请求对话框一起发送的请求和应用生成的请求是不同的,您不能使用应用生成的请求来邀请用户加入您的应用。

通过图表api无法发送Facebook应用程序请求。您可以使用app requests java-script dialog来发送请求,但您只需在文档中详细说明在“to”属性中指定用户的标识。

采样功能:

<script> 
    FB.init({ appId: '**appId**', status: true, cookie: true, xfbml : true }); 

    function sendRequest(to) { 
    FB.ui({method: 'apprequests', to: to, message: 'You should learn more about this awesome site.', data: 'tracking information for the user'}); 
    return false; 
    } 
</script> 

然后刚丝为每个图像一个onclick喜欢的东西onclick="return sendRequest('**friendId**');"

你也可以调用在JavaScript这样的功能:它会给你的照片所有的朋友。还有一群正在使用相同应用的朋友。您可以向其中的任何人发送请求。

function sendRequestViaMultiFriendSelector() { 
    FB.ui({ 
     method: 'apprequests', 
     message: "You should learn more about this awesome site." 
    });  
} 

Facebook Friend Request - Error - 'All users in param ids must have accepted TOS'

+0

我想从应用程序发送它。 – Gugan

+0

然后,您只能将其发送给安装了您的应用的用户 – Igy

相关问题