API create user error with empty result
-
I am trying to create a user using the remote API operations with s2member PRO.
I based my code on the sample that exists inside the “s2member pro api scripting” section.
The code works 97% of the times. In some occasions it fails for no apparent reason.$post_data = stream_context_create (array(“http” => array(“method” => “POST”, “header” => “Content-type: application/x-www-form-urlencoded”, “content” => “s2member_pro_remote_op=” . urlencode (serialize ($op)))));
$result = trim (file_get_contents (“http://www.example.com/team/?s2member_pro_remote_op=1”, false, $post_data));
fwrite($file, “s2m api res: “.print_r($result,true).”\n”);
if (!empty($result) && !preg_match (“/^Error\:/i”, $result) && is_array($user = @unserialize ($result))) {
//
} else {
die(“API error reads: ” . $result);
};This gets into the “else” section of of the if, with empty “$result” (I don’t see no output). The output to the $file above the if also shows that the $result variable is empty.
An example $op input to the $post_data above.
op: Array
(
[op] => create_user
[api_key] => XXX_MY_KEY_XXX
[data] => Array
(
[user_login] => blablauser
[user_email] => blabla@gmail.com
[modify_if_login_exists] => 1
[first_name] => My Name
[last_name] =>
[s2member_level] => 1
[s2member_subscr_id] => PG-12345678
[custom_fields] => Array
(
[my_field_id] => Some value.
)[s2member_notes] => Administrative notation. Created this User via API call.
[user_pass] => 123456
[notification] => 1
))
How can I check what is wrong?
The topic ‘API create user error with empty result’ is closed to new replies.