Opt in user error handler


(Delgesh_Shahab) #1

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
    (
    )

)


(Pav) #2

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


(John Borelli) #3

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

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


(Delgesh_Shahab) #4

Thanks John,

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

thanks


(John Borelli) #5

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


(Delgesh_Shahab) #6

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

i am not getting any errors

thanks


(John Borelli) #7

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


(Delgesh_Shahab) #8

Thanks for your reply.

I create stand alone file, still retrieving same problem.

Can you please provide me an example for this?


(John Borelli) #9

What is the return value as I described doing above?


(Delgesh_Shahab) #10

Same thing what happend above. it’s crashes …


(John Borelli) #11

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


(Delgesh_Shahab) #12

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


(Jon Smith) #13

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


(Delgesh_Shahab) #14

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

thanks


(John Borelli) #15

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


(Delgesh_Shahab) #16

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);


(John Borelli) #17

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.


(Delgesh_Shahab) #18

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…


(John Borelli) #19

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…?