imgrooot Posted August 9, 2017 Share Posted August 9, 2017 I am using this API https://github.com/blocktrail/blocktrail-sdk-php. I am suppose to add this to top of my directory where I want to initialize the API. require 'vendor/autoload.php'; use Blocktrail\SDK\BlocktrailSDK; But the second line gives me an error. use Blocktrail\SDK\BlocktrailSDK; Parse error: syntax error, unexpected 'use' (T_USE) in C:\xampp\htdocs\site\templates\header.php on line 12 Is the "use" a correct syntax for php? Why is it giving me an error? Link to comment Share on other sites More sharing options...
kicken Posted August 9, 2017 Share Posted August 9, 2017 what do you have above that line? Your error says it's line 12. Link to comment Share on other sites More sharing options...
Jacques1 Posted August 9, 2017 Share Posted August 9, 2017 The error is on line 12, you've posted two lines. How exactly are we supposed to figure out the rest? Mind reading? Link to comment Share on other sites More sharing options...
imgrooot Posted August 9, 2017 Author Share Posted August 9, 2017 what do you have above that line? Your error says it's line 12. Line 12 is the "use Blocktrail\SDK\BlocktrailSDK;" code listed above it. Link to comment Share on other sites More sharing options...
imgrooot Posted August 9, 2017 Author Share Posted August 9, 2017 I actually did tried this on a test page outside of the normal site and it gives me this error. I'm pretty sure I installed it correctly using composer. Fatal error: Uncaught Blocktrail\SDK\Connection\Exceptions\ObjectNotFound: The object you've tried to access does not exist. in C:\xampp\htdocs\gift\composer\vendor\blocktrail\blocktrail-sdk\src\Connection\RestClient.php:336 Stack trace: #0 C:\xampp\htdocs\gift\composer\vendor\blocktrail\blocktrail-sdk\src\Connection\RestClient.php(306): Blocktrail\SDK\Connection\RestClient->responseHandler(Object(GuzzleHttp\Psr7\Response)) #1 C:\xampp\htdocs\gift\composer\vendor\blocktrail\blocktrail-sdk\src\Connection\RestClient.php(173): Blocktrail\SDK\Connection\RestClient->request('GET', 'address/1NcXPMR...', NULL, NULL, NULL, NULL, NULL) #2 C:\xampp\htdocs\gift\composer\vendor\blocktrail\blocktrail-sdk\src\BlocktrailSDK.php(162): Blocktrail\SDK\Connection\RestClient->get('address/1NcXPMR...') #3 C:\xampp\htdocs\gift\test.php(28): Blocktrail\SDK\BlocktrailSDK->address('1NcXPMRaanz43b1...') #4 {main} thrown in C:\xampp\htdocs\site\composer\vendor\blocktrail\blocktrail-sdk\src\Connection\RestClient.php on line 336 Link to comment Share on other sites More sharing options...
kicken Posted August 9, 2017 Share Posted August 9, 2017 We know what line 12 is. We want to know what lines 1-11 are. Link to comment Share on other sites More sharing options...
imgrooot Posted August 9, 2017 Author Share Posted August 9, 2017 We know what line 12 is. We want to know what lines 1-11 are. Other files like include init.php include_once 'metas.php'; include_once 'analyticstracking.php'; and so on. They are non related to the API. Link to comment Share on other sites More sharing options...
Jacques1 Posted August 9, 2017 Share Posted August 9, 2017 Dude. The syntax error isn't in line 12, it's in one of the lines before that. If you want help with a syntax problem, then we need to actually see the exact code, not an “and so on” placeholder. Is this really so hard to understand? Anyway, apparently you've repaired your secret code now. The new error is an interal library exception. Read the source code to understand why it's happening. Link to comment Share on other sites More sharing options...
imgrooot Posted August 9, 2017 Author Share Posted August 9, 2017 Dude. The syntax error isn't in line 12, it's in one of the lines before that. If you want help with a syntax problem, then we need to actually see the exact code, not an “and so on” placeholder. Is this really so hard to understand? Anyway, apparently you've repaired your secret code now. The new error is an interal library exception. Read the source code to understand why it's happening. The error says invalid credentials, I assume it means my API key. I double checked it and it's the correct key. I am testing it on a test.php page with this code . require_once 'composer/vendor/autoload.php'; use \Blocktrail\SDK\BlocktrailSDK; $client = new BlocktrailSDK("0012a34a76bf10cf01c53d0c6059fc84a22f8e9d", "22250773dfde8f4ed0a0252a299549e9c024b132", "BTC", true /* testnet */); $address = $client->address('1NcXPMRaanz43b1kokpPuYDdk6GGDvxT2T'); $latestBlock = $client->blockLatest(); var_dump($address['balance'], $latestBlock['hash']); And this is the error i receive. Fatal error: Uncaught Blocktrail\SDK\Connection\Exceptions\ObjectNotFound: The object you've tried to access does not exist. in C:\xampp\htdocs\gift\composer\vendor\blocktrail\blocktrail-sdk\src\Connection\RestClient.php:336 Stack trace: #0 C:\xampp\htdocs\gift\composer\vendor\blocktrail\blocktrail-sdk\src\Connection\RestClient.php(306): Blocktrail\SDK\Connection\RestClient->responseHandler(Object(GuzzleHttp\Psr7\Response)) #1 C:\xampp\htdocs\gift\composer\vendor\blocktrail\blocktrail-sdk\src\Connection\RestClient.php(173): Blocktrail\SDK\Connection\RestClient->request('GET', 'address/1NcXPMR...', NULL, NULL, NULL, NULL, NULL) #2 C:\xampp\htdocs\gift\composer\vendor\blocktrail\blocktrail-sdk\src\BlocktrailSDK.php(162): Blocktrail\SDK\Connection\RestClient->get('address/1NcXPMR...') #3 C:\xampp\htdocs\gift\test.php(7): Blocktrail\SDK\BlocktrailSDK->address('1NcXPMRaanz43b1...') #4 {main} thrown in C:\xampp\htdocs\gift\composer\vendor\blocktrail\blocktrail-sdk\src\Connection\RestClient.php on line 336 Link to comment Share on other sites More sharing options...
imgrooot Posted August 9, 2017 Author Share Posted August 9, 2017 Alright so I figured out why it was giving me that error. The reason I was getting the above error was because the wallet address I had in the call was EMPTY. It had no transactions sent or received so it was returning the default error. All I have to do now is set up my own custom error if the wallet is empty. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.