Skip to Content Skip to Menu

[SOLVED] Simple Use Case Request for CB Auto Actions with cURL after Registration

10 years 8 months ago - 10 years 8 months ago #241073 by prestoproducts
Can you please provide a simple use case for sending the username in a cURL request after it is submitted in the registration form?

Here is my cURL code:

$curl = curl_init();
curl_setopt($curl, CURLOPT_VERBOSE, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
curl_setopt($curl, CURLOPT_URL, ' OtherWebsiteToSendDataAfterRegistration.com/index.php?username='.$username .'');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$Response = curl_exec($curl);
curl_close($curl);

The cURL code sends off the username value from registration and then gets a unique id back. I am going to take that id and use it elsewhere, but for now I need to know how I can use CB Auto Actions to take the username input from the registration field and then fire it away in this php code. Thank you for your time.
Last edit: 10 years 8 months ago by krileon.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48477
  • Thanks: 8281
  • Karma: 1443
10 years 8 months ago - 10 years 8 months ago #241082 by krileon
Use CB Auto Actions and the Request action. It's designed specifically to send HTTP requests. It also completely supports substitutions. See the below example request action URL.

URL:
Code:
http://www.example.com/data.php?username=[username]

You can send GET/POST/XML/JSON requests with the request action. Currently it uses our Snoopy library, but next release will be completely cURL based. Snoopy works fine in most cases except it has issues with https usage depending on server configuration.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
Last edit: 10 years 8 months ago by krileon.

Please Log in or Create an account to join the conversation.

10 years 8 months ago #241105 by prestoproducts
Thank you for the prompt reply. Okay, so with the Request function I can send the information out... that's great. I know that the server I am sending the info to is https based, so I am currently running some tests to see if that is going to cause a problem.

As I mentioned, when the call is sent out to the master server, it kicks back a unique identifier. I have to then take that value and add it to a user field for the CB user. Can you please provide an outline for the second CB Auto Action that I should take to pick up that value? I can have the value returned in JSON format if that helps:

{uniqueId:1233456}

Please Log in or Create an account to join the conversation.

10 years 8 months ago #241106 by prestoproducts
hmm... well I ran a test with the debug script active and this is what I got:
Code:
object(CBSnoopy)#571 (41) { ["host"]=> string(11) "www.php.net" ["port"]=> int(80) ["proxy_host"]=> string(0) "" ["proxy_port"]=> string(0) "" ["proxy_user"]=> string(0) "" ["proxy_pass"]=> string(0) "" ["agent"]=> string(13) "Snoopy v1.2.3" ["referer"]=> string(0) "" ["cookies"]=> array(0) { } ["rawheaders"]=> array(0) { } ["maxredirs"]=> int(5) ["lastredirectaddr"]=> string(0) "" ["offsiteok"]=> bool(true) ["maxframes"]=> int(0) ["expandlinks"]=> bool(true) ["passcookies"]=> bool(true) ["user"]=> string(0) "" ["pass"]=> string(0) "" ["accept"]=> string(56) "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*" ["results"]=> string(0) "" ["error"]=> string(0) "" ["response_code"]=> string(0) "" ["headers"]=> array(0) { } ["maxlength"]=> int(500000) ["read_timeout"]=> int(30) ["timed_out"]=> bool(false) ["status"]=> int(0) ["temp_dir"]=> string(4) "/tmp" ["curl_path"]=> string(19) "/usr/local/bin/curl" ["_maxlinelen"]=> int(4096) ["_httpmethod"]=> string(3) "GET" ["_httpversion"]=> string(8) "HTTP/1.0" ["_submit_method"]=> string(4) "POST" ["_submit_type"]=> string(33) "application/x-www-form-urlencoded" ["_mime_boundary"]=> string(0) "" ["_redirectaddr"]=> bool(false) ["_redirectdepth"]=> int(0) ["_frameurls"]=> array(0) { } ["_framedepth"]=> int(0) ["_isproxy"]=> bool(false) ["_fp_timeout"]=> int(30) }

Can you help me understand this output? I did not get the expected JSON identifier back.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48477
  • Thanks: 8281
  • Karma: 1443
10 years 8 months ago - 10 years 8 months ago #241124 by krileon
There is no return value handling for the Request action. You'll have to use PHP with a custom cURL call then push the returned value to the CB user object.

In your custom code you can still use substitutions so to send the username you'd still use [username] in your code. Example as follows based off your above usage.

Code:
curl_setopt($curl, CURLOPT_URL, 'OtherWebsiteToSendDataAfterRegistration....username=[username]');

You can then establish a user object as follows.

Code:
$user = cbUser::getUserDataInstance( '[user_id]' ); $user->set( 'FIELD_NAME', 'VALUE' ); $user->store();


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
Last edit: 10 years 8 months ago by krileon.
The following user(s) said Thank You: prestoproducts

Please Log in or Create an account to join the conversation.

10 years 8 months ago #241152 by prestoproducts
That solved it! Thank you.

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum