comparison php/read/similar.php @ 42:3f400072bf14

merge, involved ediff3 wrt getAmazonInfo.php
author Charlie Root
date Sat, 05 Jan 2019 06:21:12 -0500
parents d606320ec331
children d9dd9705e724
comparison
equal deleted inserted replaced
41:0578c6e438d3 42:3f400072bf14
104 $crl = curl_init(); 104 $crl = curl_init();
105 $timeout = 5; 105 $timeout = 5;
106 curl_setopt ($crl, CURLOPT_URL,$url); 106 curl_setopt ($crl, CURLOPT_URL,$url);
107 curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1); 107 curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1);
108 curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout); 108 curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout);
109 $gotit=0;
110 $semaphore = new SyncSemaphore("Amazon");
111 $gotit = $semaphore->lock(1000);
112 if (!$gotit) {
113 file_put_contents('/var/ywww/debug/phpDebug',
114 "Got it: ".(int)$gotit." 4\n",FILE_APPEND);
115 $gotit = $semaphore->lock(1000);
116 file_put_contents('/var/ywww/debug/phpDebug',
117 "Got it: ".(int)$gotit." 4a\n",FILE_APPEND);
118 }
109 $ret = curl_exec($crl); 119 $ret = curl_exec($crl);
110 curl_close($crl); 120 curl_close($crl);
121 usleep(500000);
122 if ($gotit) {
123 $semaphore->unlock();
124 }
125 else {
126 file_put_contents('/var/ywww/debug/phpDebug',
127 "Unlocking 4\n",FILE_APPEND);
128 }
111 //echo $ret; 129 //echo $ret;
112 130
113 $xml = new SimpleXMLElement($ret); 131 $xml = new SimpleXMLElement($ret);
114 132
115 //$isbn1 = $xml->Items->Request->SimilarityLookupRequest->ItemId; 133 //$isbn1 = $xml->Items->Request->SimilarityLookupRequest->ItemId;