class representing session (logged user). You must log in using this object before making any other requests.
Methods:
constructor Gpf_Api_Session($url) – creates session object. You have to specify full valid URL to the /scripts/server.php file of your installation.
For example: http://www.yoursite.com/affiliate/scripts/server.php
login($username, $password, $roleType, $languageCode) – authorizes the user and creates session object. The username and password must be your merchant or affilaite login information.
By default the user is considered to be a merchant. If you want to log in as an affiliate, you have to specify the third parameter $roleType = self::AFFILIATE.
$languageCode parameter is optional. If you do not specify any value for this parameter, default language will be used. Language can be secified by its code e.g. en-US, de-DE, sk, cz, ...
If
login was successful, it returns true, otherwise false. If you use incompatible API version, login throws Gpf_Api_IncompatibleVersionException (see bellow for more details).
setDebug(true/false) – sets debugging. If you set it to true, it will output every request and response in JSON format.
getMessage() - returns error message in case of error
Logging in as merchant:
$session = new Gpf_Api_Session("http://demo.qualityunit.com/pax4/scripts/server.php");
if(!$session->login("merchant@example.com", "demo")) {
die("Cannot login. Message: ".$session->getMessage());
}
Logging in as affiliate
$session = new Gpf_Api_Session("http://demo.qualityunit.com/pax4/scripts/server.php");
if(!$session->login("affiliate@example.com", "demo", Gpf_Api_Session::AFFILIATE)) {
die("Cannot login. Message: ".$session->getMessage());
}
Of course, as an affiliate you don't
have access to the functionality of merchant, for example to the list
of all affiliates.
If you want to redirect user (merchant/affiliate) to his panel after Gpf_Api_Session is created you can do it using following code:
// redirecting to merchant panel (requires merchant session)
header('Location: '.$session->getUrlWithSessionInfo('http://demo.qualityunit.com/pax4/merchants/index.php'));
// redirecting to affiliate panel (requires affiliate session)
header('Location: '.$session->getUrlWithSessionInfo('http://demo.qualityunit.com/pax4/affiliates/panel.php'));
<?php
include_once('PapApi.class.php');
$session = new Gpf_Api_Session('http://www.example.com/affiliate/scripts/server.php');
if ($papversion = $session->getAppVersion()) {
echo 'Post Affiliate Pro version: ' . $papversion;
} else {
echo 'Failed to load version with error: ' . $session->getMessage();
}
?>$session = new Gpf_Api_Session('http://demo.qualityunit.com/pax4/scripts/server.php');
try {
if (!$session->login('merchant@example.com', 'demo')) {
die("Unable to login: ".$session->getMessage());
}
echo "logged";
} catch (Gpf_Api_IncompatibleVersionException $e) {
echo "Download new API file here: ".$e->getApiDownloadLink();
}Method getApiDownloadLink() in Gpf_Api_IncompatibleVersionException returns full url o the PapApi.class.php file of the installation you are connecting to so you can download it and update your PapApi.class.php file.
Change LogIf you don't have latest release of product, please take a look into our change log. Maybe your problem was already resolved in newer release and you can just upgrade your installation to resolve the problem.
Review Change log
|
Road MapHave you suggestion, how to improve our products? Maybe same suggestion is already reported in our road map and you don't need to contact us because of it.
Review Roadmap
|
Bug TrackerIf you want to report bug, please take a look into our opened bugs. Maybe same bug was already reported. Please don't report same bug next time!
Review opened bugs
|
Phone SupportPhone support is offered only in English.
Toll Free (USA & Canada): 1-877-374-3995
Skypein: 1-415-8303923 Skype Phone: quality.unit Other: +421-911-023006 |
New Support TicketPlease search for an answer in our knowledgebase first. You might find your answer faster than by contacting us!
Submit New Ticket
|
|
All the menu items will lead |
||
Affiliate softwarePost Affiliate Pro 4Powerful affiliate software to power your affiliate program Customer supportSupport CenterHelpdesk, email management and KB LiveAgentLive Chat for your web Other productsPost Member ProMembership software Unit MinerWeb data extraction |
||
|
Earn commission for referring our products Affiliate program |
||