Authorize.net DPM, How To? - php

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);

Related

Prestashop 1.7 using Import csv function programmatically

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'));
}

Issue with third party Google Analytics sdk

I have code which works above the php 5
its actually GA Library, here is its github project.
I have cloned the project theiconic/php-ga-measurement-protocol
Since I am new to PHP, I have no idea where to put this code, Please help me here this project should be installed via composer via code
{
"require": {
"theiconic/php-ga-measurement-protocol": "^2.0"
}
}
After this step I need to create a file something.php and I need to put the code below, I am having problem on locating autoload.php on my server, Please look at the code below to understand what i am saying.
<?php
//grab the data that Calendly sent in the webhook and store it in a variable called $objCalendlySubmission...
$objCalendlySubmission = json_decode(file_get_contents('php://input'));
//We've passed the Google client_id in Calendly's placeholder for utm_term. Feel free to pass it differently, this is just an example
if(property_exists($objCalendlySubmission->payload->tracking, 'utm_term') && !empty($objCalendlySubmission->payload->tracking->utm_term)) {
$strPageViewed = 'calendly_conversion.html'; // We use different page names depending on what type of event was scheduled via Calendly
sendGoogleAnalyticsPageView($objCalendlySubmission->payload->tracking->utm_term, $strPageViewed);
}
function sendGoogleAnalyticsPageView($strGAClientId, $strURL) {
require_once '/path_to_composer/composer/vendor/autoload.php'; //loads the PHP library for the "Google Analytics Measurement Protocol” **I dont know where is it located exactly on my xampp server, Please guide me here**
$analytics = new TheIconic\Tracking\GoogleAnalytics\Analytics(true); //you may have to adjust this path based on your setup **please help me here**
$analytics
->setProtocolVersion('1')
->setTrackingId('YOUR-GA-UA-ID-GOES-HERE')
->setClientId($strGAClientId)
->setDocumentLocationUrl($strURL);
$analytics->sendPageview();
}
?>
In the above code towards middle line
require_once '/path_to_composer/composer/vendor/autoload.php'; //loads the PHP library for the "Google Analytics Measurement Protocol”
I dont know where is it located exactly on my xampp server, Please guide me here
$analytics = new TheIconic\Tracking\GoogleAnalytics\Analytics(true); //you may have to adjust this path based on your setup
Here is the image of Project folder
Project structure Part 2

CakePhp Getting Entity 'raquo' not defined error when calling SOAP wdsl file

Im trying to connect to the FedEx PHP plugin, Ive successfully ran the plugin with my local Server. But when I try to run it on my CakePhp project I get the next error:
SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://my-subdomain.mydomain.com/controller/wsdl' : Entity 'raquo' not defined
Using the url I can actually enter the wdsl page and see the file in XML file. I got a function and view which return this. This is that functions code:
public function wsdl() {
$this->layout = false;
$this->RequestHandler->respondAs('xml');
}
I can enter the url and see the correct display of the XML. Then when I try using the wsdl on my function which is in the same class I get the error above. This is the code I use to call the SOAP class:
//The WSDL is not included with the sample code.
//Please include and reference in $path_to_wsdl variable.
$path_to_wsdl = "http://apibebe2go.bebe2go.com/home/wsdl";
ini_set("soap.wsdl_cache_enabled", "0");
$client = new SoapClient($path_to_wsdl, array('trace' => 1));
I get and internal error from the CakePhp debug and the error above. Any ideas what I could try to make this work? If you guys need any more code Ill be happy to help :D
Ok I solved the problem another way. Not sure why the /wdsl file was not working when called via function to view, BUT I added the .wdsl file to the WebRoot file path I had and called the url from there. Now it works like it should. If you need further explanation on how I achieved this, feel free to ask here :D
Cheers! :P

Using the Flickr API how can I get back the absolute path to an image?

Ok, this is not only how to get the URL to an image, it is a little more than that and I proceed to explain trying to be as clear as possible, I might point out that I am a totally newbie on this, I am a PHP Junior programmer and this is my first time using Flickr at all:
I have PHP website online, I have done all what is related to Key, Secret, Token and that. So basically I have a public image uploader that works fine. You could go into my website pick a picture and upload them to my Flickr account.
Now, they PHP for doing that is basically this one:
$apiKey = "(my API Key)";
$apiSecret = "(my API Secret)";
$permissions = "write";
$token = "(my Token)";
$f = new phpFlickr($apiKey, $apiSecret, true);
$f->setToken($token);
$f->sync_upload($path, $title);
return $f;
The phpFlickr object comes in the Flickr API, and $f in this case gives me back an array with the picture ID and some other data.
How can I get an absoulte path to the just uploaded picture in the form www.flickr.com/something/myPicture.jpg in order to build a HTML tag?
Probably what $f gives me is not enough. Any light over this would be great!
Hope it was clear.
Before I start writing, take a look at these links. They might have what you're looking for:
http://www.flickr.com/services/api/misc.urls.html
http://www.flickr.com/services/api/flickr.photos.getInfo.html
If you're trying to build an absolute path to a photo, you have to build the entire path based on the information that you get from a successful API call which is going to be located in $f. Looking at the first link I posted, there are a few ways to build an absolute path for a picture given that you have all of the information needed. The first method is to build the photo source URL, which comes in this format:
http://farm{farm-id}.staticflickr.com/{server-id}/{id}_{secret}.jpg
or
http://farm{farm-id}.staticflickr.com/{server-id}/{id}_{secret}_[mstzb].jpg
or
http://farm{farm-id}.staticflickr.com/{server-id}/{id}_{o-secret}_o.(jpg|gif|png)
The information required to build these links can be found in a successful call to the photos.getInfo API call that I posted above. Building the absolute path is as simple as just combining all of the variables together:
(I haven't touched PHP in a while, bear with me)
my $link = 'http://farm' . $farmid . '.staticflickr.com/' . $serverid . '/' . $id . '_' . $secret . '.jpg';
The second method is to build the webpage URL. This can either be grabbed directly from the photos.getinfo API call, or built manually given that you have the user-id and/or photo-id. If you have the required information, building the link is almost the same as the way I did it above. Check out the first link I posted for the actual URLs you need to build.
One last thing I should mention is that you should make sure that your API calls are working. I spent so much wasted time back when I was first learning how to use API's because I never checked the output of what the API calls were returning or my authentication was incorrect. Doing a vardump($f) (or something similar) and seeing what the calls are returning might help you visualize what needs to be done to get the information you need.
Ok, I just found how. In case anyone is interested:
$f = new phpFlickr($apiKey, $apiSecret, true);
$f->photos_getInfo(PHOTO_ID);
That gives you back an array with all what you need to complete the URL.

Class AlchemyAPI not found error

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)

Categories