Difference between revisions of "Affiliate Remote Login"
Offeritnick (talk | contribs) |
|||
(8 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
{{Offerit Manual | {{Offerit Manual | ||
− | | | + | | show_affiliate_area_section = true |
}} | }} | ||
− | You can create a custom form for affiliates to | + | You can create a custom form for affiliates to log in to your Offerit installation. All that is needed is to create a form that submits to the following url: |
<pre> | <pre> | ||
− | http://< | + | http://<tracking domain>/internal.php |
</pre> | </pre> | ||
− | You would replace < | + | You would replace <tracking domain> with the [[Ct#Tracking Domain|Tracking Domain]] of your Offerit install. The only variables that need to be sent for a successful login with the post are "user" and "pass". If the user is submitting fails to enter the correct login information they and they are posting from the tracking domain of your offerit install they will be redirected to the external login page of your offerit install. Otherwise they will receive an error response regarding why their login was unsuccessful. |
Here is a basic example of what this form may look like. | Here is a basic example of what this form may look like. | ||
Line 22: | Line 22: | ||
</pre> | </pre> | ||
− | [[ | + | <h3>Displaying your own error page</h3> |
+ | If you prefer to display your own errors, you can send a post to verify the username and password are correct before sending the user. For instance use javascript to handle the form submission and send an ajax post to a validation script like this one: | ||
+ | <pre> | ||
+ | $response = array( | ||
+ | 'result' => 'fail' | ||
+ | ); | ||
+ | if ( ! empty( $_POST['user'] ) && ! empty( $_POST['pass'] ) && check_length( $_POST['user'], 2, 255 ) && check_length( $_POST['pass'], 3, 255 ) ) { | ||
+ | $response_headers = get_headers( AFFILIATE_URL . '/internal.php?user=' . $_POST['user'] . '&pass=' . $_POST['pass'] . '', 1 ); | ||
+ | if ( array_key_exists( 'Location', $response_headers ) && strpos($response_headers[0], 'HTTP/1.1 302') !== FALSE ) { | ||
+ | $response = array( | ||
+ | 'result' => 'success' | ||
+ | ); | ||
+ | } | ||
+ | } | ||
+ | </pre> | ||
+ | If the post returns success, you can let the form submit like normal. If the post returns error, you can tell the surfer to try again. | ||
+ | |||
+ | |||
+ | <h3>Displaying Forgot Password</h3> | ||
+ | Similarly, you can trigger forgot password from your own page and check for your own errors by making it an ajax call instead of a direct form submission. The post script might look like this one: | ||
+ | <pre> | ||
+ | $response = array( | ||
+ | 'result' => 'fail' | ||
+ | ); | ||
+ | parse_str( $_POST['formdata'], $data ); | ||
+ | $curl = curl_init(); | ||
+ | curl_setopt( $curl, CURLOPT_URL, AFFILIATE_URL . '/submit.php' ); | ||
+ | curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true ); | ||
+ | curl_setopt( $curl, CURLOPT_POST, true ); | ||
+ | curl_setopt( $curl, CURLOPT_POSTFIELDS, http_build_query( $data ) ); | ||
+ | $response['response'] = curl_exec( $curl ); | ||
+ | $header = curl_getinfo( $curl, CURLINFO_HTTP_CODE ); | ||
+ | curl_close( $curl ); | ||
+ | preg_match( '#<div class="action-details">(.+?)</div>#is', $response['response'], $found ); | ||
+ | if ( $header === 302 ) { | ||
+ | $response = array( | ||
+ | 'result' => 'success', | ||
+ | 'message' => 'An email has been sent with your new password. ', | ||
+ | 'header' => $header | ||
+ | ); | ||
+ | } | ||
+ | if ( $header === 200 ) { | ||
+ | if ( $found ) { | ||
+ | $response = array( | ||
+ | 'result' => 'error', | ||
+ | 'message' => $found[1], | ||
+ | 'header' => $header | ||
+ | ); | ||
+ | } | ||
+ | } | ||
+ | </pre> | ||
+ | |||
[[Category:Offerit Affiliate Information]] | [[Category:Offerit Affiliate Information]] |
Latest revision as of 13:58, 9 October 2018
You can create a custom form for affiliates to log in to your Offerit installation. All that is needed is to create a form that submits to the following url:
http://<tracking domain>/internal.php
You would replace <tracking domain> with the Tracking Domain of your Offerit install. The only variables that need to be sent for a successful login with the post are "user" and "pass". If the user is submitting fails to enter the correct login information they and they are posting from the tracking domain of your offerit install they will be redirected to the external login page of your offerit install. Otherwise they will receive an error response regarding why their login was unsuccessful.
Here is a basic example of what this form may look like.
<!-- Simple form to post to Offerit and login --> <form action="http://example.offerit.com/internal.php" method="post"> Username: <input type="text" name="user" /><br /> Password: <input type="password" name="pass" /><br /> <input type="submit" /> </form>
Displaying your own error page
If you prefer to display your own errors, you can send a post to verify the username and password are correct before sending the user. For instance use javascript to handle the form submission and send an ajax post to a validation script like this one:
$response = array( 'result' => 'fail' ); if ( ! empty( $_POST['user'] ) && ! empty( $_POST['pass'] ) && check_length( $_POST['user'], 2, 255 ) && check_length( $_POST['pass'], 3, 255 ) ) { $response_headers = get_headers( AFFILIATE_URL . '/internal.php?user=' . $_POST['user'] . '&pass=' . $_POST['pass'] . '', 1 ); if ( array_key_exists( 'Location', $response_headers ) && strpos($response_headers[0], 'HTTP/1.1 302') !== FALSE ) { $response = array( 'result' => 'success' ); } }
If the post returns success, you can let the form submit like normal. If the post returns error, you can tell the surfer to try again.
Displaying Forgot Password
Similarly, you can trigger forgot password from your own page and check for your own errors by making it an ajax call instead of a direct form submission. The post script might look like this one:
$response = array( 'result' => 'fail' ); parse_str( $_POST['formdata'], $data ); $curl = curl_init(); curl_setopt( $curl, CURLOPT_URL, AFFILIATE_URL . '/submit.php' ); curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true ); curl_setopt( $curl, CURLOPT_POST, true ); curl_setopt( $curl, CURLOPT_POSTFIELDS, http_build_query( $data ) ); $response['response'] = curl_exec( $curl ); $header = curl_getinfo( $curl, CURLINFO_HTTP_CODE ); curl_close( $curl ); preg_match( '#<div class="action-details">(.+?)</div>#is', $response['response'], $found ); if ( $header === 302 ) { $response = array( 'result' => 'success', 'message' => 'An email has been sent with your new password. ', 'header' => $header ); } if ( $header === 200 ) { if ( $found ) { $response = array( 'result' => 'error', 'message' => $found[1], 'header' => $header ); } }