Jump to content

NetMonkey

New Members
  • Posts

    2
  • Joined

  • Last visited

NetMonkey's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. A lot of what you mentioned makes sense. So if I lose line 42 the first array should be fine correct? I should do something to call my function on line 18. (thanks developer on wordpress.stackexchange.com) who suggested the code... Now the rest starts to get confusing and seems like more reading on php.net... Thanks.
  2. Hey guys, Sorry, php noob here, but can grasp new concepts rather quickly. I've been in IT a long time and this is my first time trying to rewrite this much php code. I've been working on this php script for 7 days now and think I'm getting close. I've seen most every syntax error, have learned a lot and morphed the code into what it is now. The script I'm hacking was written back in 09 with 16 (static) user data fields in an array to test register a user at a third-party website via SSL with curl and a simple xml load string. If you get a success response, all went well with the other server. If not, all you get is a fail response. The first 6 data fields will still remain static, but the last 10 will always vary because I'm querying a WP user DB to get user data. The script just queries the WP user DB creates an array and posts to the other server and registers the user, so the user that registered with the first site doesn't have to go through the whole registration process over again. This is totally G-rated. It's for a consumer discounts site. Here's what I'm trying to get the code to do. Create an array, query the DB and then pass the first static array data and the user array data to the post string and get a success response from the other server. This is the whole script that's failing and I'm only able to see, Status: fail. Nice error code huh? Here's my code: error_reporting(E_ALL); ini_set('display_errors',true); // Set the Query POST parameters $query_vals = array( 'api_username' => 'api-name-here', 'api_password' => 'api-password', 'api_key' => 'key-goes-here', 'perkalert' => 0, 'offer_radius' => 20, 'send_welcome_email' => 1 ); // Call WordPress function wp_get_current_user_info() //Create array function wp_get_current_user_info() { $current_user = wp_get_current_user(); $current_user-> $value; $n="user_variable_{$type}_name"; ${$n} = true; $current_user_info = array( 'firstname' . $current_user->user_firstname =>'n', 'lastname' . $current_user->user_lastname =>'n', 'address' . $current_user->mepr-address-one =>'n', 'city' . $current_user->mepr-address-city =>'n', 'state' . $current_user->mepr-address-state =>'n', 'zip' . $current_user->mepr-address-zip =>'n', 'country' . $current_user->mepr-address-country =>'n', 'email' . $current_user->user_email =>'n', 'username' . $current_user->user_login =>'n', 'password' . $current_user->user_pass =>'n' ); return $current_user_info; } $postdata = ''; $key = '='; $value = '&' $query_vals = array(); $current_user_info = array(); $result = array_merge($query_vals, $current_user_info); { foreach($query_vals as $key => $value); foreach($current_user_info as $key => $value); $postdata .= $key.'='.urlencode($value).'&'; } // Chop of the trailing ampersand $postdata = rtrim($postdata, '&'); // create a new cURL resource $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://secureserver/client/register_member.xml'); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata); // Save response to a string $response = curl_exec($ch); curl_close($ch); $xml = simplexml_load_string($response); //var_dump($xml); echo "Status: ".$xml->status; Any help is really appreciated. Thanks.
×
×
  • 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.