echo ',??????? :7777777 77 ', PHP_EOL; echo ' =????? ,7777777 77= ', PHP_EOL; echo ' +?+ 7777777? ', PHP_EOL; echo ' + ~7777777 ', PHP_EOL; echo ' I777777 ', PHP_EOL; echo ' :~ ', PHP_EOL; echo PHP_EOL; echo PHP_EOL; echo '############################################', PHP_EOL; echo '# Image Keyword Example #', PHP_EOL; echo '############################################', PHP_EOL; echo PHP_EOL; echo PHP_EOL; echo 'Processing Image URL: ', $demo_url, PHP_EOL; echo PHP_EOL; $response = $alchemyapi->image_keywords('url', $demo_url, array('extractMode' => 'trust-metadata')); if ($response['status'] == 'OK') { echo '## Response Object ##', PHP_EOL; echo print_r($response); echo PHP_EOL; echo '## Image Keywords ##', PHP_EOL; foreach ($response['imageKeywords'] as $imageKeywords) { echo 'image keyword: ', $imageKeywords['text'], PHP_EOL; echo 'score: ', $imageKeywords['score'], PHP_EOL; echo PHP_EOL; } } else { echo 'Error in the image keyword extraction call: ', $response['statusInfo']; } echo PHP_EOL; echo PHP_EOL;
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ require_once 'alchemyapi.php'; $alchemyapi = new AlchemyAPI(); $test_text = 'Bob broke my heart, and then made up this silly sentence to test the PHP SDK'; $test_html = '<html><head><title>The best SDK Test | AlchemyAPI</title></head><body><h1>Hello World!</h1><p>My favorite language is PHP</p></body></html>'; $test_url = 'http://www.nytimes.com/2013/07/13/us/politics/a-day-of-friction-notable-even-for-a-fractious-congress.html?_r=0'; $imageName = "grumpy-cat-meme-hmmm.jpg"; $imageFile = fopen($imageName, "r") or die("Unable to open file!"); $imageData = fread($imageFile, filesize($imageName)); fclose($imageFile); //image keywords echo 'Checking image keywords . . . ', PHP_EOL; $response = $alchemyapi->image_keywords('url', $test_url, null); assert($response['status'] == 'OK'); $response = $alchemyapi->image_keywords('image', $imageData, array('imagePostMode' => 'raw')); assert($response['status'] == 'OK'); $response = $alchemyapi->image_keywords('random', $test_url, null); assert($response['status'] == 'ERROR'); //invalid flavor echo 'Image keyword tests complete!', PHP_EOL, PHP_EOL; //image extraction echo 'Checking image extraction . . . ', PHP_EOL; $response = $alchemyapi->imageExtraction('url', $test_url, null); assert($response['status'] == 'OK'); $response = $alchemyapi->imageExtraction('random', $test_url, null); assert($response['status'] == 'ERROR'); //invalid flavor echo 'Image extraction tests complete!', PHP_EOL, PHP_EOL;