0

I am working on Dropbox-API php..

My php file just working in CLI.. How to make it works in CGI as well?

this is my search.php

<html>
<pre>
<?php
echo "123";

require_once "dropbox-sdk/Dropbox/autoload.php";
use \Dropbox as dbx;

$accessToken = "xxx";
$dbxClient = new dbx\Client($accessToken, "PHP-Example/1.0");
$_SESSION['Dropbox'] = $dbxClient;

$searchMetadata = $dbxClient->searchFileNames( "/", "soemarko.png", null, false );
print_r($searchMetadata);

$file = "search.json";
file_put_contents($file, json_encode($searchMetadata));

$searchUrl = $dbxClient->createShareableLink("/Soemarko.png");

$link = "link.json";
file_put_contents($link, json_encode($searchUrl));



?>
</pre>
</html>

And i have a form to redirect there in different file..

<form action="search.php" method="POST"> 
<input type="text" name="query"/>
<input type="Submit" value="Submit">
</form>

Can anyone please help me to make my search.php run in browser? It currently just show blank page..

Even i tried to add

header(Location: 'display.php')

is ignored and keep showing blank page in search.php

ComFreek
  • 29,044
  • 18
  • 104
  • 156
AlbertSamuel
  • 584
  • 10
  • 33

1 Answers1

0

The only difference why some code could run in CGI or CLI and not the other is because you have different php.ini for each version of PHP installed on your system. I know for one that our CentOS servers at work have 2 folders for PHP, one CLI and one APACHE/HTTP and both have different configs.

What i recommend is that you run

phpinfo()

on the web one and look at the modules loaded and the version of PHP. Then, from the command line, run the CLI version using:

php -v
php -m

And compare the version and module list.

You'll probably find that the json module is not installed in the one that doesn't work and thats why it fails!

Mathieu Dumoulin
  • 12,126
  • 7
  • 43
  • 71