Opt in user error handler

I am trying to Opt in for a user based on email address, but getting error.

	global $infusionsoft;

	$infusionsoft->refreshAccessToken();


	//opt in user
	$billing = $order->get_address( $type = 'billing' );
	$email = $billing['email'];
	error_log('email is '.$email);

	$optIn = $infusionsoft->emails('optIn', $email, 'I have Permission box was checked');

//// Error Message
WP_Error Object
(
[errors] => Array
(
[invalid-request] => Array
(
[0] => No such handler: EmailsService.optIn
)

    )

[error_data] => Array
    (
    )

)

Sounds like a bug in the SDK. The Email Service handler is “APIEmailService”.

https://developer.infusionsoft.com/docs/xml-rpc/#email-opt-in-an-email-address

The above line is wrong according to documentation it should be:

$infusionsoft->emails()->optIn($email, ‘I have Permission box was checked’);

Thanks John,

I am still getting error, which document are you referring to.

thanks

Going from the code you posted, you’re using the api (not iSDK)…documentation for optin for the api can be found here:

https://developer.infusionsoft.com/docs/xml-rpc/#email-opt-in-an-email-address

Also, what is the post back you are getting. ie make it

$return=$infusionsoft->emails()->optIn($email, ‘I have Permission box was checked’);
var_dump($return);

I’m asking this way because the error you’re showing is a WP error

when i implement the example code, it crashes the website.

i am not getting any errors

thanks

Then test away from your framework. Create a stand alone file that gets the message for you.

Thanks for your reply.

I create stand alone file, still retrieving same problem.

Can you please provide me an example for this?

What is the return value as I described doing above?

Same thing what happend above. it’s crashes …

Then it’s not api related. Either syntax or server. So place die(); after each line, one at a time, and see how far down you can go before it crashes. Then focus on the structure or function of that specific line. Also, ensure that error_reporting is set to E_ALL

thanks for your help and fast reply, I well debugging to find the problem.

@Del_Chefv
Try using APIEmailService.optIn instead of EmailsService.optIn as this appears to be the issue

Thanks @JonSmith where can I find APIEmailService in https://developer.infusionsoft.com/docs/xml-rpc/#introduction

thanks

https://developer.infusionsoft.com/docs/xml-rpc/#email-opt-in-an-email-address

the example code what is displayed in the library did not work for me.

After debugging I found this call was working for me:
$optin = $infusionsoft->APIEmail(‘optIn’, $email, ‘I have Permission box was checked’);
var_dump($optin);

But i am getting bool(false);

If the email is already opted in then the return value will be false. You will only get a true when an email that is currently unmarketable will return true and then will return false every time there after.

Thanks, @John_Borelli, every example code in PHP from the library did not work out for me.

My solution is :metal:
$infusionsoft->emails()->getOptStatus($email)

should be…

$infusionsoft->APIEmail( ‘getOptStatus’, $email);

@JonSmith Maybe updating the Libary will be useful or something is wrong on my side…

You could submit a request for that doc to be updated. The methods you have indicated you used in the first place, they all work for me. You shouldn’t need to get the status. blindly optin the email. What changes for you if they’re opted out already or already opted in, that you need to know that this particular time the call returned true? The results are still the same…?