1 | <?php |
||
14 | |||
15 | final class Service |
||
16 | { |
||
17 | /** |
||
18 | * The solvemedia server URL's |
||
19 | */ |
||
20 | const ADCOPY_API_SERVER = 'http://api.solvemedia.com'; |
||
21 | const ADCOPY_API_SECURE_SERVER = 'https://api-secure.solvemedia.com'; |
||
22 | const ADCOPY_VERIFY_SERVER = 'http://verify.solvemedia.com/papi/verify'; |
||
23 | const ADCOPY_SIGNUP = 'http://api.solvemedia.com/public/signup'; |
||
24 | |||
25 | private $_client; |
||
26 | private $_pubkey; |
||
27 | private $_privkey; |
||
28 | private $_hashkey; |
||
29 | |||
30 | /** |
||
31 | * Construct a Service object with the required api key values. |
||
32 | * |
||
33 | * @param ClientInterface $client The guzzle client to send the requests over. |
||
34 | * @param string $pubkey A public key for solvemedia |
||
35 | * @param string $privkey A private key for solvemedia |
||
36 | * @param string $hashkey An optional hash key for verification |
||
37 | * @throws Exception |
||
38 | */ |
||
39 | public function __construct(ClientInterface $client, $pubkey, $privkey, $hashkey = '') |
||
50 | |||
51 | /** |
||
52 | * Gets the challenge HTML (javascript and non-javascript version). |
||
53 | * This is called from the browser, and the resulting solvemedia HTML widget |
||
54 | * is embedded within the HTML form it was called from. |
||
55 | * |
||
56 | * @param string $error The error given by solvemedia (optional, default is null) |
||
57 | * @param boolean $useSsl Should the request be made over ssl? (optional, default is false) |
||
58 | * @return string The HTML to be embedded in the user's form. |
||
59 | */ |
||
60 | public function getHtml($error = null, $useSsl = false) |
||
74 | |||
75 | /** |
||
76 | * Calls an HTTP POST function to verify if the user's guess was correct |
||
77 | * |
||
78 | * @param string $remoteip |
||
79 | * @param string $challenge |
||
80 | * @param string $response |
||
81 | * @throws Exception |
||
82 | * @return TraderInteractive\SolveMedia\Response |
||
83 | */ |
||
84 | public function checkAnswer($remoteip, $challenge, $response) |
||
130 | |||
131 | /** |
||
132 | * Gets a URL where the user can sign up for solvemedia. If your application |
||
133 | * has a configuration page where you enter a key, you should provide a link |
||
134 | * using this function. |
||
135 | * |
||
136 | * @param string $domain The domain where the page is hosted |
||
145 |