dev-ria Posted September 28, 2012 Share Posted September 28, 2012 hi, I am trying to use the sample code provided by amazon awis to get alexa ranking. found here: http://aws.amazon.com/code/402?_encoding=UTF8&binField_1=type&binValue_1=code&fromSearch=1&queryArg=searchQuery&searchQuery=awis%20php but i want to be able to get rankings using my website rather than using a command prompt. i've been getting some help from the forum but nothing has fixed my issue. i keep getting $argv undefined here is the code http://semesterold.com/code2.html Quote Link to comment https://forums.phpfreaks.com/topic/268889-using-command-line-to-run-php-file/ Share on other sites More sharing options...
requinix Posted September 28, 2012 Share Posted September 28, 2012 Help from where? I don't see anything from you having to do with this. Only the code at the very bottom forces it to be a command-line script. Remove it and write something else in its place so that you can do whatever you want. Meanwhile the code in the class outputs stuff directly so for the time being you might want to use a PRE or stick to a text-only page. Otherwise what's your code? Quote Link to comment https://forums.phpfreaks.com/topic/268889-using-command-line-to-run-php-file/#findComment-1381631 Share on other sites More sharing options...
dev-ria Posted September 28, 2012 Author Share Posted September 28, 2012 well i dont have any code in there. I am trying to display alexa details (ranking, views etc) using the amazon api. I just edited the bottom portion. removed the if statement and put //if (count($argv) < 1) { //echo "Usage: site\n"; //exit(-1); //} //else { $accessKeyId = "XXX"; $secretAccessKey = "XXX"; $site = "google.com"; //} now i have an issue with curl_init. I'm using wamp and turned on curl but still i get Call to undefined function curl_init() is there another way to run this instead of using curl function? Quote Link to comment https://forums.phpfreaks.com/topic/268889-using-command-line-to-run-php-file/#findComment-1381639 Share on other sites More sharing options...
premiso Posted September 28, 2012 Share Posted September 28, 2012 file_get_contents works if fopen_wrappers is on. But, to enable Curl in WAMP, you sometimes have to edit the php.ini and uncomment the extension line to the php_curl.dll and then save. Quote Link to comment https://forums.phpfreaks.com/topic/268889-using-command-line-to-run-php-file/#findComment-1381640 Share on other sites More sharing options...
dev-ria Posted September 28, 2012 Author Share Posted September 28, 2012 how do i use file_get_contents in this case? i did edit my php.ini file here ;extension=php_bz2.dll extension=php_curl.dll <--- ;extension=php_dba.dll extension=php_mbstring.dll ;extension=php_exif.dll ;extension=php_fileinfo.dll extension=php_gd2.dll ;extension=php_gettext.dll ;extension=php_gmp.dll ;extension=php_intl.dll ;extension=php_imap.dll restarted wamp and still get the same error. shouldn't curl show up in phpinfo() as on or something? cause I can't find it there. Quote Link to comment https://forums.phpfreaks.com/topic/268889-using-command-line-to-run-php-file/#findComment-1381643 Share on other sites More sharing options...
premiso Posted September 28, 2012 Share Posted September 28, 2012 It should show up under phpfinfo. The only thing I can think of is that your CLI script is using a different ini file. If you were on Linux, I could show you a command how to tell easily, but since you are not, open up the command prompt and run: php -r 'phpfinfo();' And it should spit out a ton of stuff in text, look for the .ini line and make sure that is the .ini you are changing. Quote Link to comment https://forums.phpfreaks.com/topic/268889-using-command-line-to-run-php-file/#findComment-1381647 Share on other sites More sharing options...
Christian F. Posted September 28, 2012 Share Posted September 28, 2012 Note that PHP CLI and PHP CGI may have different php.ini files, and thus different settings. Not to mention they might have been compiled differently, so that some core functionality is not available on the CLI version. So when testing with php -r 'phpinfo ();' you're getting the results for the CLI version only. To get the specifics for the CGI version as well you need to run it via the web browser. Quote Link to comment https://forums.phpfreaks.com/topic/268889-using-command-line-to-run-php-file/#findComment-1381649 Share on other sites More sharing options...
dev-ria Posted September 28, 2012 Author Share Posted September 28, 2012 that didnt work for me. I did find the php.ini files made changes but still no luck. i want to move away from using curl and wanted to see how else i can run it without curl. how would i change that line to move away from curl Quote Link to comment https://forums.phpfreaks.com/topic/268889-using-command-line-to-run-php-file/#findComment-1381650 Share on other sites More sharing options...
premiso Posted September 28, 2012 Share Posted September 28, 2012 protected static function makeRequest($url) { echo "\nMaking request to:\n$url\n"; $result = file_get_contents($url);//'wget -bq -o /dev/null $url >/dev/null 2>&1'; return $result; } Quote Link to comment https://forums.phpfreaks.com/topic/268889-using-command-line-to-run-php-file/#findComment-1381653 Share on other sites More sharing options...
dev-ria Posted September 28, 2012 Author Share Posted September 28, 2012 you are the best!!! that worked perfectly!! Quote Link to comment https://forums.phpfreaks.com/topic/268889-using-command-line-to-run-php-file/#findComment-1381656 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.