Reputation: 10552
Hey all i am running my own PHP server (via WAMP) and using the provided Walgreens API PHP example to test out uploads for photos.
Below is some of my code where it seems to be stopping:
$affiliateId = "xxxxx";
$apiKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxx";
$apiEndPoint = "https://services-qa.walgreens.com/api/util/mweb5url";
$cred_data = array(
"serviceType"=>"wagS3",
"act"=>"genCredV2",
"view"=>"genCredV2JSON",
"affId"=> $affiliateId,
"apiKey"=>$apiKey,
"devinf"=>"IE,11",
"appver"=>"0.01"
);
$cred_data=json_encode($cred_data);
echo "<br/>Credential Request = ",$cred_data;
$headers = array('Content-type: application/json; charset=utf-8');
$curl = curl_init($apiEndPoint);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_POSTFIELDS, $cred_data);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$cred_response = curl_exec($curl);
echo "<br/>Credential Response = ",$cred_response,"<br/>";
$cred_response = json_decode($cred_response,TRUE);
curl_close($curl);
When I place this onto my other server being hosted with a hosting company and run the php file it works just fine (giving the echo "< br/>Credential Response = ",$cred_response,"< br/>"; an actual response.).
However, when I run the code on my local machine it doesn't give anything back as a response like its being blocked or something?
The response back I get from the other server is:
Credential Request = {"serviceType":"wagS3","act":"genCredV2","view":"genCredV2JSON","affId":"xxxxx","apiKey":"xxxxxxxxxxxxxxxxxxxxxxxxxxxx","xxxxxx":"IE,11","appver":"0.01"}
Credential Response = {"uploadUrl":"http://xxxxxxxxxxxxx.com","secretKey":"xxxxxxxxxxxxxxxxxxxx","sessionId":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","err":"","accessKeyId":"xxxxxxxxxxxxxxxxxxxxxxxx"}
The response back I get from my local server is:
Credential Request = {"serviceType":"wagS3","act":"genCredV2","view":"genCredV2JSON","affId":"xxxxx","apiKey":"xxxxxxxxxxxxxxxxxxxxxxxxxxxx","xxxxxx":"IE,11","appver":"0.01"}
Credential Response =
Am i missing a setting or a plugin in either my Apache and/or PHP files?
Upvotes: 0
Views: 245
Reputation: 91
The correct answer is you must have an affiliateID and apikey that is setup by the walgreens team. So this is not valid:
$affiliateId = "xxxxx";
$apiKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxx";
Must be something like this:
$affiliateId = "extest1";
$apiKey = "BLAHBLAHBLAHBLAH";
Per the documentation on the developer portal you must register for an account to create an APIkey (https://developer.walgreens.com/user/register)
Upvotes: 0
Reputation: 94672
I have had problems like this, the issue is that the WALGreen server cannot find localhost
and probably wont even bother looking when it see that domain.
If you set up a dymanic DNS service so that your PC (well the router rather) can be found with an actual domain name, even if the domain name is a little oddly named, it will start to work.
Dont forget to port forward port 80 on yuor router to the ip of the PC running WAMP. Its also a good idea to create a Virtual Host on your local Apache so the domain names i.e. the dynamic dns name and the internal domain name match.
Upvotes: 1