I tried the following code to post a question on my facebook wall but it fails. But posting question alone (without options) is working fine.
mPostButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
try{
Bundle params = new Bundle();
params.putString("question", "My first Qusetion ?");
JSONObject options = new JSONObject();
try{
options.put("Opt1",true);
options.put("Opt2",false);
}
catch(Exception e){}
params.putString("options",options.toString());
String response = facebook.request("me/questions",params,"POST");
}catch(Exception e){}
});
}
Try using
JSONArrayinstead of aJSONObject, and make sure that the JSONArray’s.toString()function makes an output string that looks like["hiking", "parking"]because that is how we expect the options parameter to be like. You can try it in the Graph API explorer to verify it works, I just did with a POST tome/questionswith aquestionparameter and anoptionsparameter with the value being above.