Integrating coinsecure api give me error..? - php

I want to integrate coinsecure api in my code, Here is the url for api which I have used.
Url : https://github.com/coinsecure/plugins/tree/master/master/php/SwaggerClient-php
Where there are two method to install/integrate API :
Using composer.
Manual process.
So I have select second one manual Process so based on document information
Download all file and add into my third part library folder.
And add require_ones autoload.php file.
Up to this step it'll fine but problem is now occur when I have perform action using this coin secure.
Suppose I want to get lowest rate over the last 24 hours so for that one bellow code is provided by api.
Code :
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$api_instance = new Swagger\Client\Api\ExchangeTradeDataApi();
$accept = "accept_example"; // string | JSON, XML or CSV can be returned (Optional)
try {
$result = $api_instance->v1exchangemin24Hr($accept);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling ExchangeTradeDataApi->v1exchangemin24Hr: ', $e->getMessage(), PHP_EOL;
}
?>
And when I run this code it'll give me error as below :
[404] Error connecting to the API
(https://api.coinsecure.in/v1/exchange/max24Hr)
Can any one have idea why it give me error..?

Strange, there's an extra / in your URL before the v1 causing a 404 error. Instead it should be https://api.coinsecure.in/v1/exchange/max24Hr
Looks like their PHP library is hard coded wrong.
From their github library line 76
if ($apiClient == null) {
$apiClient = new ApiClient();
$apiClient->getConfig()->setHost('https://api.coinsecure.in/');
}
Then they include the / again on line 136
$resourcePath = "/v1/exchange/ask/low";
Notice how the base url ends with a / and the path starts with a /. You can change it yourself and it should work, but I bet the other calls in the library are messed up too. Maybe let them know so they can correct the library.
Location: plugins/master/php/SwaggerClient-php/lib/Api/ExchangeTradeDataApi.php

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

Facebook php SDK - simple datafetch

I'm trying to integrate my facebook app with PHP. What I need to do is have users go to the app-page, authenticate the app and then somehow I want to end up with a variable that contains the info I need so I can store it in MySQL.
I downloaded the facebook SDK, but I cannot figure out how to make it work. All the examples I can find refer to a file called facebook.php - but there is no such file in the SDK (maybe the changed it?).
I managed to get it working with JavaScript, but I don't know how to get from JavaScript to php (the user object, that is).
I would prefer to just run it entirely through php. What I'm trying to do is very simple, but I don't understand what I'm doing wrong. The following, for instance, does not work:
<?php
FacebookSession::setDefaultApplication('appid', 'appsecret');
require facebook-php-sdk-v4-master\src\Facebook\FacebookCanvasLoginHelper.php;
$helper = new FacebookCanvasLoginHelper();
try {
$session = $helper->getSession();
} catch(FacebookRequestException $ex) {
echo "error";
} catch(\Exception $ex) {
echo "error 2";
}
if ($session) {
echo "logged in";
}
?>
Gives PHP Fatal error: Class 'FacebookSession' not found in
Where do I go? I don't think the Facebook getting started guide is helpful at all. It just starts out with "you have to do this" (what I did above) - but that doesn't work?
Looks like they changed the whole SDK for PHP 5.4.
Well there's a few options, you could go with the older SDK and all those tutorials you found will work for that. Or you could learn some new things!
I suggest that if you want to use the new Facebook SDK, you go ahead an learn about composer first, it makes including libraries a piece of cake and all you'd have to do is include the autoloader at the top of the file. Once done, you can just follow the example and it should work.
If you don't want to learn composer, you'll have to include all the required files manually. Here's a basic example.
In your example it looks like the error was because you were calling
FacebookSession::setDefaultApplication
Before you'd actually included the SDK

Trouble Importing PHP Class

I am working with an API that has a "supported" library written by a third party.
I've done as the instructions say and feel I am very close to getting it working as it should however no matter what I try, (renaming, absolute paths, aggregated file paths, etc.) I'm getting the same error.
*I have an API key. This is not the issue
The error arises in this block:
define('API_KEY', ''); // //-- Insert your API key
define('PHP_SELF', htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8'));
require_once("FFN.class.php");
$ffn = new FFN(API_KEY); //where actual error is thrown
if (!API_KEY) {
echo 'You did not set the API_KEY for your application. This is required.';
exit;
}
And states:
PHP Fatal error: Class 'FFN' not found in /st/3/g/public_html/path/nerdapi.php on line 16
The actual error is thrown on $ffn = new FFN(API_KEY);
If anyone can spot my probably very obvious error, I'd really appreciate it.
Here is the site where I got the 3rd party code for the API's
https://github.com/philip/FantasyNerdAPI
i download the file, and put up these file:
FFN.class.php
sdk.php
on htdocs/a and accessing localhost/a/sdk.php
result was : You did not set the API_KEY for your application. This is required.
well, i didnt put the key.

UserVoice API Call in PHP

Can anyone please give a Simple Example of UserVoice API call in PHP that retrieve something (could be anything like article etc etc) because i am unable to find any Example that is doing something like that...!!
I have seen at many Places even i searched a lot before using it that is there any example for PHP to retrieve the data using UserVoice API but unable to find so after lots of things i found solution myself here is an example i am posting but few things needed:
Make Sure you have the API Key which you can get by going in Settings>Channels
Apply for the API Client in the API section clicking "Add API client" button fill the form and it will generate a API Key and some other useful information
Now Open your PHP File Lets say you want to get all the articles on your Website using API then you can use following code:
$r = new HttpRequest('https://YOUR_DOMAIN_NAME/api/v1/articles.json', HttpRequest::METH_GET);
$r->addQueryData(array('client' => 'INSERT_YOUR_API_KEY_HERE'));
try {
$r->send();
if ($r->getResponseCode() == 200) {
$obj=json_decode($r->getResponseBody());
print_r($obj);
}
}
catch (HttpException $ex) {
echo $ex;
}

Authorize.net DPM, How To?

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

Categories