Connect.registerUsers - Need helping creating array for accounts param

Posted by mw_javaguy on Stack Overflow See other posts from Stack Overflow or by mw_javaguy
Published on 2009-10-10T00:14:23Z Indexed on 2010/04/05 12:03 UTC
Read the original article Hit count: 245

I keep getting the following error when I try to invoke the Facebook REST API Call:

Connect.registerUsers

Error Code: 100 - param accounts must be an array

JSON based response (from Facebook):

{"error_code":100,"error_msg":"param accounts must be an array.","request_args":
[{"key":"accounts","value":"{email_hash:5232156322_55ddgvc3db5ddcf218049dd564da2x06}"},
{"key":"api_key","value":"23b2c4c6a23445fbffssf8aab96a5e5"},
{"key":"format","value":"JSON"},{"key":"method","value":"Connect.registerUsers"},{"key":"sig","value":"3sd54153a31382fa6e72eecf3c57d7c9"},{"key":"v","value":"1.0"}],"message":"Unknown exception","code":0}

I set up the Java code to invoke the REST end point using HttpClient like this:

String API_KEY = "23b2c4c6a23445fbffssf8aab96a5e5";
String toConnectRegisterUsersSignature = 
   "accounts=" 
   + "{email_hash:" +  emailHash + "}"
   + "api_key=" + API_KEY
   + "format=JSON"
   + "method=Connect.registerUsers"
   + "v=1.0"
   + "0c786155bd3cxe8228d924542da5gf2";

String connectRegisterUsersSignature = SimpleMd5.MD5(toConnectRegisterUsersSignature);

NameValuePair[] connectRegisterUsersParameters =
{ 
    new NameValuePair("accounts", "{email_hash:" +  emailHash + "}"),
    new NameValuePair("api_key", API_KEY),
    new NameValuePair("format", "JSON"),
    new NameValuePair("method", "Connect.registerUsers"),
    new NameValuePair("sig", connectRegisterUsersSignature),
    new NameValuePair("v", "1.0") 
};

Tried the following combinations and I still get the same error!

Signature: "accounts=" + "[email_hash=" + emailHash + "]"
new NameValuePair("accounts", "[email_hash=" + emailHash + "]")

Signature: "accounts=" + "email_hash[" + emailHash + "]"
new NameValuePair("accounts", "email_hash[" + emailHash + "]")

Signature: "accounts=" + "email_hash(" + emailHash + ")"
new NameValuePair("accounts", "email_hash(" + emailHash + ")")

Signature: "accounts=" + "[email_hash=" + emailHash + "]"
new NameValuePair("accounts", "[email_hash=" + emailHash + "]")

Signature: "accounts=" + "email_hash=" + emailHash
new NameValuePair("accounts", "email_hash=" + emailHash)

Signature: "accounts=" + "[{email_hash:" +  emailHash + "}]"
new NameValuePair("accounts", "[{email_hash:" +  emailHash + "}]"),

Does anyone know how to construct this array that the response is requesting?

Happy programming and thank you for taking the time to read this.

© Stack Overflow or respective owner

Related posts about facebook

Related posts about facebook-api