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