I need help guys, are you familiar with the alchemy api? It's an SEO tool that runs on different platforms and what it does is extract contents from web pages it uses the principle of content scraping.
I downloaded the php SDK for alchemy api and I got an error I cannot load the page and if anyone here in this forum that is familiar with alchemy api or good with php i really need your help guys. the error says:
Fatal error: Class 'AlchemyAPI' not found in line 44
Here is my code:
function CheckNoParams() {
$alchemyObj = new AlchemyAPI(); // line 44
$alchemyObj->loadAPIKey("api_key.txt");
$htmlFile = file_get_contents("../example/data/example.html");
$htmlFile2 = file_get_contents("../example/data/example2.html");
}
Looks like you haven't use include. Try this:
function CheckNoParams() {
include "./module/AlchemyAPI.php";
$alchemyObj = new AlchemyAPI(); // Now line 45 :-P
$alchemyObj->loadAPIKey("api_key.txt");
$htmlFile = file_get_contents("../example/data/example.html");
$htmlFile2 = file_get_contents("../example/data/example2.html");
}
(Assuming you have preserved the original file structure when you downloaded the Alchemy's PHP SDK)
Related
I state that I'm not familiar with Prestashop and I'm using version 1.7.6.
I'm trying to understand how I could use the import function from csv file without using of user interface.
I tried to look for documentation on a possible web api but I found nothing.
What I'd like to accomplish is the following scenario:
I have two web applications on the same server
/my_webapp
/my_prestashop
By "my_webapp" I receive a csv file, process it and produce a new csv file.
Now continuing running the process in "my_webapp", I would like to instantiate the ambient of the prestashop application to invoke the import csv function by passing it the new file just created.
Searching the web I found some sample code but, trying to use and adapt it, I am not making it work.
For example, on “my_webapp” folder I just create a “myimport.php” file and call it with two GET parameters.
The following is the call:
localhost/my_webapp/myimport.php?csv=prod.csv&limit=5
note: the file “prod.csv” is on
"path to admin folder"/import
Content of “myimport.php” file:
<?php
$rootPrestashop = '/var/www/html/my_prestashop”;
define('_PS_ADMIN_DIR_', $rootPrestashop.'/admin_shop'); //not sure if this instruction is needed
$pathConfig = $rootPrestashop.'/config/config.inc.php';
$initConfig = $rootPrestashop.'/init.php';
require_once($pathConfig);
require_once($initConfig); //this line throw an error and then I can't test the others!
$importCtrl = new AdminImportControllerCore();
$crossSteps = array();
$limit = $_GET["limit"];
$importCtrl->productImport(false, $limit, $crossSteps, true, 0);
This is what I’m trying to do, but I failed to initialize the environment.
Maybe I’m on the wrong way and there’s a better way.
I ask if anyone can help me understand if I can carry out this process and what would be the correct way.Thanks in advance
if (!defined('_PS_ADMIN_DIR_')) {
define('_PS_ADMIN_DIR_', __DIR__);
}
include _PS_ADMIN_DIR_.'/../config/config.inc.php';
if (!Context::getContext()->employee->isLoggedBack()) {
Tools::redirectAdmin(Context::getContext()->link->getAdminLink('AdminLogin'));
}
I have no idea about PHP programming before. Now I am working on selenium using Facebook php web driver. I have just started with very basic test code that is to open pages and click links and so on. But I got stuck just after few lines of code and it shows a parse error. I couldn't find what the parse error is? It would really grateful if someone can help me out. Here is my few lines of code..
<?php
use Facebook\WebDriver\Remote\DesiredCapabilities;
use Facebook\WebDriver\Remote\RemoteWebDriver;
require_once 'vendor/Autoload.php';
$host = 'http://localhost:4444/wd/hub'; // this is the default
$capabilities = DesiredCapabilities::firefox();
$driver = RemoteWebDriver::create($host, $capabilities, 5000);
$driver->get('http://qa.practera.com');
$link =$driver>findElement(WebDriverBy::xpath('//a[#href='login']'));
$link->click();
?>
Result:
Parse error: parse error in
/Users/srujanareddyenugala/Desktop/php-webdriver/1.php on line 14
I am an intern and trying to learn by looking at some examples because my mentor just want me to learn by myself. I want to start from basics but they are not giving me enough time and wants me to do just by going through examples and understand. It will be very helpful if someone can help me by giving advices how to learn quickly and also could suggests me with some websites or books or online courses.
Thanks in advance!!
This line
$link =$driver>findElement(WebDriverBy::xpath('//a[#href='login']'));
To
$link =$driver->findElement(WebDriverBy::xpath('//a[#href='login']'));
you are missing a - sign
I am attempting to build a PHPMailer based email system for a basic website.
This is the line of code that is giving me trouble:
$xajax->printJavascript('xajax/');
Now, this is the tutorial I am using.
Regarding the above line of code, the tutorial says this:
How to use the code inside a webpage?
Place the form (variable), the function (and the includes) before of all html code. Next we need to include some JavaScript file in the documents HTML header (place also php tags):
$xajax->printJavascript('xajax/');
When I run all of the code (including: PHPMailer script; Ajax script), I get this error, on the aforementioned line of code.
Fatal error: Call to a member function on a non-object
So, my question is, do I need to in someway customize this code or make it run to a filepath of some ajax core file or something?
I would be willing to be $xajax is not defined. Try adding this after including the libraries but before including the call to that method:
$xajax = new xajax();
There may be some additional setup required by xajax. A more complete code example could help troubleshoot.
I found the DPM PHP SDK on authorize.net at http://developer.authorize.net/api/dpm/, and tried to test but it's not working, the page displays the error: Warning: require_once(PHPUnit/Framework.php).
Does someone know how to resolve this, or can provide me with step by step tutorial?
It seems a requirement of the following statement has been forgotten
The PHP SDK contains a helper function that implements a demonstration of the Direct Post Method in one line of code. Copy and paste the code below into a new file named "direct_post.php" and fill in any incomplete variables. Make sure your server is publicly accessible and that the $url variable points to this new file.
look at a short tutorial
Tutorial "15 Minutes or less"
I just had to create a php file and put this code:
require_once 'anet_php_sdk/AuthorizeNet.php'; // The SDK
$url = "http://YOUR_DOMAIN.com/file_I_created.php";
$api_login_id = 'YOUR_API_LOGIN_ID';
$transaction_key = 'YOUR_TRANSACTION_KEY';
$md5_setting = 'YOUR_API_LOGIN_ID'; // Your MD5 Setting
$amount = "5.99";
AuthorizeNetDPM::directPostDemo($url, $api_login_id, $transaction_key, $amount, $md5_setting);
I am making use of this script to get the first item of my Twitter feed. However, it is slow (it takes 3 to 4 seconds to load page now). Why is it so slow?
Here is how I use it.
require_once 'rss_php.php'; //see link above
$rss = new rss_php;
$rss->load('http://twitter.com/statuses/user_timeline/XXXXXX.rss');
$feed = $rss->getItems(false, 1);
echo $feed[0]['title'];
echo $feed[1]['title'];
I do get this PHP notice:
Notice: Undefined variable: tempNode
in
C:\wamp\www\rss_php.php
on line 137
I don't know why since this works, line 137 is this line:
return $tempNode;
Thanks all for any help. I appreciate any advice on speeding this up.
Fetching content from a remote location can potentially introduce some rather ugly loading issues.
Try saving the contents of the RSS feed in a local file and see if the problem persists when loading from a local drive.
If this fixes the issue, you should look into caching the contents of the feed every once in a while.
Firstly, line 110 of your pastbin is assigning a variable that was never declared. As such, any requests or assignments to an undeclared variable will do this. From what I see it should be as simple as adding $tempNode = Array(); just below the function call of the extractDOM method.
Next, since this is a script from someone else I would recommend asking them what you can do to improve performance. From what is in the pastbin I don't see anything elaborate going on, nor do I see you using the library incorrectly, but ultimately they would know better.
After line 138 in rss_php.php (v.1 Free version) file paste this:
...
if (!isset($tempNode)){
$tempNode = null;
}
return $tempNode;
...
Enjoy
;)
Getting rid of that return $tempNode; notice is easy, but not your problem, it just needs to be defined out of the forloop in that extractDOM function.
Optimizing your php code is a big task. I'm assuming that the api call is the majority of the time, but if you want to try and speed your code up a bit I would look into tutorials on how to do that:
http://ilia.ws/archives/12-PHP-Optimization-Tricks.html
http://progtuts.info/55/php-optimization-tips/
http://hungred.com/useful-information/php-micro-optimization-tips/