3

I want to start by saying I have searched extensively, including google, connect.squareup.com, and Stack Overflow and cannot find an answer to my question. I have posed this question to Square support, and (even though I mentioned I could not access command line and have already done the tutorial mentioned below, I was directed to said tutorial and told to use the command line that I can't use. Here's my problem...

I am trying to set up the square connect API on a webserver for a client. On the webserver, I do not have access to command line (or SSH without an additional cost to the client). The only ways I have found to get the location_id requires command line (as far as I can tell). Is there a way to not have to use command line? Or is there another way to put in the required command without command line access?

Here is what I have done so far:

I read somewhere (can't remember where now) that you can install composer locally, use command line on your machine to install the dependencies needed for square-connect, then move all the files to your server. I have done that to get the files on the server.

My file structure looks like this: payment-portal/ vendor/ composer/ square/ autoload.php composer.json composer.json composer.lock composer.phar locations-test.php process-card.php

The locations-test.php contains:

<?php
require 'vendor/autoload.php';
$access_token = "ACCESS_TOKEN";
$location_api = new \SquareConnect\Api\LocationApi();
echo $location_api->listLocations($access_token);

Note: ACCESS_TOKEN has been replaced with my personal access token.

Of coarse, if I access this file at mywebpage.com/payment-portal/locations-test.php, I get a blank page.

Also, I am not getting any errors in the error log.

The way to get locations is lined out here. Under "Retrieving your location IDs." I am OK up until this point, but I cannot use command line in my server to use the code:

php locations-test.php

What are my other options to get the location_id? What am I missing?

Thanks in advance for any help or direction!

codeartistgirl
  • 69
  • 2
  • 10
  • If you're getting a blank page it could mean 1 of 2 things. Either the script doesn't produce any output (in which case you'll get an HTTP 200 OK response code from the server), or the script ended with errors, but you have [`display_errors`](http://php.net/manual/en/errorfunc.configuration.php#ini.display-errors) turned off (in which case the server *should* respond with an HTTP 500 Internal Error response code). See http://stackoverflow.com/a/33665510/1878262 for more details. – Sherif Sep 08 '16 at 22:28
  • Thank you for your quick response, @Sherif! I have turned on error reporting for the site, and this was the output: – codeartistgirl Sep 08 '16 at 22:44
  • Sorry, it is too long. I will post a link is a second. – codeartistgirl Sep 08 '16 at 22:47
  • Here is a link to the file: https://1drv.ms/t/s!AlxoxUJLRzvMhSZuQEhvX2qJX1pb – codeartistgirl Sep 08 '16 at 22:51
  • I agree with @Sherif that it might be a networking issue. Have you tried running the code on a local PHP environment? – tristansokol Sep 08 '16 at 23:20
  • @tristansokol - I do not have a local php environment set up on my system. I have a new computer with windows 10, and just haven't gotten to that yet. I will contact my webserver to see if any outgoing ports are being blocked as Sherif suggested. Thanks for the help, and I'll let you know the outcome! – codeartistgirl Sep 09 '16 at 00:08

1 Answers1

1

According the php-sdk you're using for connecting to the square API, the required format for $access_token should be "Bearer YOUR_ACCESS_TOKEN" no just your access token.

/**
 * @param string $authorization The value to provide in the Authorization header of
 * your request. This value should follow the format `Bearer YOUR_ACCESS_TOKEN_HERE`.

Try using this instead and see if it works.

require 'vendor/autoload.php';
$access_token = "Bearer ACCESS_TOKEN";
$location_api = new \SquareConnect\Api\LocationApi();
echo $location_api->listLocations($access_token);

Of course, don't forget to replace the ACCESS_TOKEN part with your own access token.

Sherif
  • 11,786
  • 3
  • 32
  • 57
  • I changed it as you said, but I am still getting the same error message that was listed above. – codeartistgirl Sep 08 '16 at 22:56
  • I do realize that the file above has listLocationsWithHttpInfo(''), but the new one has ('Bearer sq......') – codeartistgirl Sep 08 '16 at 22:59
  • This could possibly be a network issue. Make sure the server you're running this PHP on has no blocked outgoing ports. Try asking the host provider for assistance with that. – Sherif Sep 08 '16 at 23:00
  • It actually doesn't matter if 'Bearer' is included in the access token. Thanks for pointing out that inconsistency though! – tristansokol Sep 08 '16 at 23:20
  • @Sherif - I will check with the webserver to see if there are any blocked outgoing ports that could be preventing this, and I will get back to you all! Thanks so much for all the help! – codeartistgirl Sep 09 '16 at 00:09
  • @Sherif - You were absolutely correct. The problem was blocked outgoing ports on the server. They have gotten it fixed and everything works beautifully!!! :) I don't have the rep to upvote, but I have accepted it as the answer! – codeartistgirl Sep 09 '16 at 00:30