0

I have a Cakephp 2.7 app that is outputting some json which I want to use on another site. The action is publicly allowed by auth in the beforeFilter...

public function beforeFilter() {
    parent::beforeFilter();
    $this->Auth->allow('api_feed');
}
public function api_feed(){

    $properties = $this->Property->find('all');
    $this->set('properties',json_encode($properties));
    $this->layout = 'ajax'; //default cake ajax layout.
    header('Content-Type: application/json'); 
}

The api_feed.ctp view file...

echo $properties;

The site that is consuming the feed is a new Wordpress Multi-site.

I've spent most of my time messing around with the syntax on the Cake output. I've tried just echoing the data with exit.

I am able to fetch the data from my local dev environment using any and all of the following: curl, file_get_contents, wp_remote_get. It shows in the browser as well, when logged out.

However, from my production server, I get nothing but drama.

Using curl:

"NULL"

Using file_get_contents:

Failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found

Using wp_get_remote:

Missing method in the controller error from Cakephp

In PHP, I have allow_url_fopen = on, allow_url_include = on.

The production server is a Digital Ocean VPS.

I'm at wits end. Any ideas on what I'm missing, or suggestions on where to look for answers?

Steve Peterson
  • 132
  • 1
  • 4
  • 16
  • Please check :-http://stackoverflow.com/questions/12294124/php-file-get-contents-not-working. please check all answer and 2 nd one is more important – Alive to die - Anant Jan 23 '16 at 00:23
  • what path are you using to access your `api_feed()` action? – Inigo Flores Jan 23 '16 at 09:52
  • @A-2-A, I'm not sure what in the other post you're refering to. – Steve Peterson Jan 23 '16 at 16:38
  • @InigoFlores the path is typical cake. controller/action. In my case, it's not a plugin, it's the propertiesController and the api_feed action. So /properties/api_feed which loads fine in a browser and can be fetched just fine from my local dev site. I configured a route just for it, but it made no difference. I actually think there are problems on both ends otherwise why/how would I be getting a missing action error from wp_remote_get. makes no sense. – Steve Peterson Jan 23 '16 at 16:43
  • Is your development server Windows by any chance? If so, make sure you've got right the case in file and folder names. I wonder if you can provide the URL to your `api_feed` action in your production server, so that I can run some tests. – Inigo Flores Jan 23 '16 at 21:22
  • It has just occurred to me... Is you production server accesible through HTTP? Or HTTPS only? – Inigo Flores Jan 23 '16 at 23:58

0 Answers0