Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and the Yahoo Answers website is now in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

How call a php API page to make it function?

I am trying to have people register at the a site and on registration a page called "mailing_list.php" sends to Email Marketer to add the user to the mailing list.

API code:

<?PHP

if ($MailingListAuth == true) {

$s_name = check_type('s_name');

$s_email = check_type('s_email');

$xml = '<xmlreques>

<username>MyAdminUserANme</username>

<usertoken>b331be66-A-TOKEN-2f1d</usertoken>

<requesttype>subscribers</requesttype>

<requestmethod>AddSubscriberToList</requestmethod>

<details>

<emailaddress>'.$s_mail.'</emailaddress>

<mailinglist>2</mailinglist>

<format>html</format>

<confirmed>yes</confirmed>

<customfields>

<item>

<fieldid>2</fieldid>

<value>'.$s_name.'</value>

</item>

</customfields>

</details>

</xmlrequest>

';

$ch = curl_init('https://example.com/mail/xml.php'); //CHANGE TO THE PATH OF YOUR IEM INSTALLATION

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_POST, 1);

curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);

$result = @curl_exec($ch);

if($result === false) {die("Error performing request");}

//var_dump($result); //for debugging purposes

//Example of how to display returned data

$xml_doc = simplexml_load_string($result);

if ($xml_doc->status == 'SUCCESS' && empty($xml_doc->data)) {die('Status is success. Empty response.');}

if ($xml_doc->status == 'SUCCESS') {

echo 'Response: <br />';

var_dump($xml_doc->data);

} else {

echo 'Error is '. $xml_doc->errormessage;

}

}

?>

What needs adding to registration page to get it work

2 Answers

Relevance
  • Jeff P
    Lv 7
    6 years ago

    Um...okay? What issue are you having? Is your script not working? Are you getting an error message? Are you not getting the expected results? Do you have any errors in your PHP error log? We can't possibly help you without knowing more information.

  • Chris
    Lv 7
    6 years ago

    Two things:

    1. Your XML code starts with <xmlreques>, the t is missing.

    2. I assume you replaced the example URL in the curl_init call with the actual URL, right?

Still have questions? Get your answers by asking now.