Jump to content

Never used PHP before, need help with an API Call


suavebum

Recommended Posts

So all my programmers are busy right now and I need to test out the on demand email feature of MyEmma by signing up a user using an API call. Unfortunately I haven't used HTML since high school, and have never used PHP (Other than pre-built PHP items). So my thought was to create an HTML page with a simple form, first name and email address. This is to be sent to MyEmma for uploading into my database of consumers. Here is the code for the simple HTML page I created:

 

<html>

<head>

<title>Personal INFO</title>

<?php

$_POST['emma_member_name_first'] = $emma_member_name_first;

$_POST['emma_member_email'] = $emma_member_name_email;

?>

</head>

<body>

<form method="post" action="/submitForm.php" onsubmit="return validateForm(this);">

<div align="center">

<table border="0" cellpadding="3" cellspacing="0">

<tbody><tr>

<td nowrap="nowrap" valign="top"><strong><font face="Verdana" size="2">First Name:</font></strong></td>

<td valign="top">

<font face="Verdana">

<!--webbot bot="Validation" b-value-required="TRUE" i-maximum-length="50" --><input name="emma_member_name_first" size="30"

 

maxlength="50" /></font><font face="Verdana" size="2">*</font><font face="Verdana">

 

</font> </td>

</tr>

<tr>

<td nowrap="nowrap" valign="top"><strong><font face="Verdana" size="2">Email:</font></strong></td>

<td valign="top">

<font face="Verdana">

<!--webbot bot="Validation" b-value-required="TRUE" i-maximum-length="50" --><input name="emma_member_email" size="30"

 

maxlength="50" /></font><font face="Verdana" size="2">*</font><font face="Verdana">

 

<tr>

<td><strong><font face="Verdana" size="2"> </font></strong></td>

<td valign="top"><input value="Submit" type="submit" name="submit" />  <input value="Reset" type="reset" /></td>

</tr>

</form>

</body>

 

 

Then I figured linking it to a php page would work. (Someone please correct me if I should use all the code in one html or php page as opposed to calling the PHP page.)

 

MyEmma gave me some sample code to use in PHP w/ PEAR. It is the code that follows:

 

require_once(HTTP/submitForm.php"

$emma_client = new HTTP_Client();

$emma_client->seMaRedirects(20);

 

// POST should be filtered appropriately

$_POST['emma_account_id'] = '12345';

$_POST['signup_post'] = '54321';

$_POST['username'] = '**username**';

$_POST['password'] = '**password**';

$_POST['group'][123456] = 1;

$_POST['emma_member_name_first'] = 'bob';

$_POST['emma_member_email'] = '[email protected];

 

$emma_client->post("https://app.e2ma.net/app/view:RemoteSignup", $_POST);

$response_code = $emma_client->currentResponse();

 

 

 

So... I directed my html page to a php file with this code:

 

<?php

require_once(HTTP/submitForm.php"

$emma_client = new HTTP_Client();

$emma_client->seMaRedirects(20);

 

// POST should be filtered appropriately

$_POST['emma_account_id'] = '12345';

$_POST['signup_post'] = '54321';

$_POST['username'] = '**username**';

$_POST['password'] = '**password**';

$_POST['group'][123456] = 1;

$_POST['emma_member_name_first'] = $emma_member_name_first;

$_POST['emma_member_email'] = $emma_member_email;

 

$emma_client->post("https://app.e2ma.net/app/view:RemoteSignup", $_POST);

$response_code = $emma_client->currentResponse();

?>

 

 

Obviously, it's not working. It's not adding any contacts to MyEmma. Any suggestions on where I could be going wrong? Whenever I try to post the PHP code in the title of my HTML page, the ->'s always screw up the coding and everything after a -> is displayed on the screen.

 

I really appreciate any help. Unfortunately I am brand new to PHP. Thank you very much!

 

(Usernames and passwords hidden for obvious reasons)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.