Codeigniter RESTserver. Null response - php

I am using Codeigniter and Phil's REStful API.
I am making a call to the server and the problem is it return a NULL value. The value that should be return is a blob that is 65000 in length. I reckon its because of the length of the blob, but I don't know how to solve this issue.
Here's how i call the api:
$resp = call('upload_api/upload/format/json/', array('uploaded_files' => $_FILES['upload'], 'file_details' => 'test'));
echo '<pre>'; print_r($resp);
public static function call($resource, $params, $method='get')
{
if (empty($params))
{
$params = array();
}
$headers = '';
$url = self::API_URL . $resource;
$curlObj = curl_init();
curl_setopt_array($curlObj,
array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 20
));
switch ($method)
{
case 'get':
$query_str = http_build_query($params);
$url = $url .= '?' . $query_str;
curl_setopt($curlObj, CURLOPT_URL, $url);
break;
case 'put':
$headers[] = 'Content-Type: application/json';
curl_setopt($curlObj, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curlObj, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($curlObj, CURLOPT_POSTFIELDS, json_encode($params));
break;
case 'post':
$headers[] = 'Content-Type: application/json';
curl_setopt($curlObj, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curlObj, CURLOPT_POST, true);
curl_setopt($curlObj, CURLOPT_POSTFIELDS, json_encode($params));
break;
default:
// error message
}
$data = curl_exec($curlObj);
$contentType = curl_getinfo($curlObj, CURLINFO_CONTENT_TYPE);
switch ($contentType)
{
case 'application/json':
$data = json_decode($data, true);
break;
}
curl_close($curlObj);
return $data;
}
Here's the method:
require APPPATH.'/libraries/REST_Controller.php';
class Upload_api extends REST_Controller {
public function upload_get()
{
$this->load->model('Upload_File');
$upload_file = new Upload_File();
$total_rows = $upload_file->count();
$upload_file->get(1, 0)->all;
// file_content is a blob
$this->response(array('file' => $upload_file->file_content, 'total_rows' => $total_rows), 200);
}
}

I'm not fully sure of the solution, but I do this when trying to solve REST bugs with the libary:
You can output:
$this->response($_SERVER);
and
$this->response($_POST);
etc. to see all the server variables, so you can check the length of the response and the headers.

Related

how to get data from mailchimp using php curl in laravel

I my Laravel app i am using php curl for mailchimp to store and get products data is storing but when i want to fetch data using foreach loop it is showing an error Trying to get property 'stores' of non-object how can i solve this thanks in advance
this is the result when i use dd()
this is the request
public function get_store()
{
$id = "store_1159";
$url = "https://us7.api.mailchimp.com/3.0/ecommerce/stores";
$data = callAPI('GET', $url, false);
$stores = json_decode($data);
//dd($stores );
$result = array();
foreach ($stores as $store) {
echo $store->id;
}
}
this is php curl main function
function callAPI($method, $url, $data=null)
{
$curl = curl_init();
switch ($method)
{
case "POST":
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
break;
case "PATCH":
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PATCH");
if ($data)
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
break;
case "DELETE":
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
default:
if($data)
$url = sprintf("%s?%s", $url, http_build_query($data));
}
$headers = array(
"--user: credentials",
"Authorization: Basic 1232132131",
"Content-Type: application/json",
"Postman-Token: 163f7134-68ca-45bb-9420-ebf2bef7f447",
"cache-control: no-cache"
);
curl_setopt_array($curl,
[
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_HEADER => false,
CURLOPT_URL => $url.'?apikey=12313123'
]);
$response = curl_exec($curl);
curl_close($curl);
return $response;
}
try this,
$data = callAPI('GET', $url, false);
$data = json_decode($data);
foreach ($data->stores as $store)
{
echo $store->id;
}

LinkedIn API - Couldn't parse share document - Json

So i'm working with the LinkedIn API and i'm trying to share something to my wall but i'm getting the following error:
Couldn't parse share document: error: Unexpected end of file after null
I think something is going wrong with with adding the HTTPHEADERS:
Content-Type: application/json
x-li-format: json
So this is what i'm trying to do:
$parameters = array("comment" => "Check out developer.linkedin.com, I'm currently testing it myself!",
"content" => array( "title" => "LinkedIn Developers Resources",
"description" => "Leverage LinkedIn's APIs to maximize engagement",
"submitted-url" => "https://developer.linkedin.com",
"ubmitted-image-url" => "https://example.com/logo.png"
),
"visibility" => array("visibility" => "anyone")
);
$result = $connection->post("people/~/shares", $parameters);
var_dump($result);
var_dump($result); shows the error message above.
And these are the functions i'm using:
public function post($path, $parameters = []){
$url = $this->createUrl($path);
$parameters = json_encode($parameters);
return $this->curlRequest('POST', $url, $parameters);
}
this is the post function, wich is using the following functions:
private function createUrl($path) {
return self::API_HOST . "/v" . self::API_VERSION . "/" . $path . "?" . self::FORMAT;
}
private function curlRequest($method, $url, $postData = NULL, $accessToken = false){
$curl = curl_init();
switch($method) {
case 'GET':
break;
case 'POST':
curl_setopt($curl, CURLOPT_POST, true);
if($accessToken) {
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($postData));
} else {
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
}
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'x-li-format: json'));
break;
}
if ($accessToken) {
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
} else {
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Authorization: Bearer ' . $this->accessToken));
}
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_URL, $url);
$result = curl_exec($curl);
curl_close($curl);
return json_decode($result, true);
}
Hope someone can help me with this problem.

refrence a variable inside a instances

This is our class that is called
<?php
class Nest
{
public $debug;
private $username;
private $password;
private $cookieFile;
public function __construct($username, $password, $debug = false)
{
// Set the properties
$this->debug = $debug;
$this->username = $username;
$this->password = $password;
$this->useragent = 'Nest/1.1.0.10 CFNetwork/548.0.4';
$this->cookieFile = tempnam('/tmp', 'nest-cookie');
// Login
$response = $this->curlPost('https://home.nest.com/user/login', 'username=' . urlencode($username) . '&password=' . urlencode($password));
if (($json = json_decode($response)) === false)
throw new Exception('Unable to connect to Nest');
// Stash information needed to make subsequence requests
$this->access_token = $json->access_token;
$this->user_id = $json->userid;
$this->transport_url = $json->urls->transport_url;
}
public function house_state_set($state)
{
switch ($state)
{
case 'away':
$away = true;
break;
case 'home':
$away = false;
break;
default:
throw new Exception('Invalid state given: "' . $state . '"');
}
$status = $this->status_get();
$structure_id = $status->user->{$this->user_id}->structures[0];
$payload = json_encode(array('away_timestamp' => time(), 'away' => $away, 'away_setter' => 0));
return $this->curlPost($this->transport_url . '/v2/put/' . $structure_id, $payload);
}
public function house_state_get()
{
$status = $this->status_get();
$structure = $status->user->{$this->user_id}->structures[0];
list (,$structure_id) = explode('.', $structure);
return ($status->structure->{$structure_id}->away ? 'away' : 'home');
}
public function temperature_set(&$temp)
{
$status = $this->status_get();
$structure = $status->user->{$this->user_id}->structures[0];
list (,$structure_id) = explode('.', $structure);
$device = $status->structure->{$structure_id}->devices[0];
list (,$device_serial) = explode('.', $device);
$temperature_scale = $status->device->{$device_serial}->temperature_scale;
if ($temperature_scale == "F")
{
$target_temp_celsius = (($temp - 32) / 1.8);
}
else
{
$target_temp_celsius = $temp;
}
$payload = json_encode(array('target_change_pending' => true, 'target_temperature' => $target_temp_celsius));
return $this->curlPost($this->transport_url . '/v2/put/shared.' . $device_serial, $payload);
}
public function status_get()
{
$response = $this->curlGet($this->transport_url . '/v2/mobile/user.' . $this->user_id);
if (($json = json_decode($response)) === false)
throw new Exception('Unable to gather the status from Nest');
return $json;
}
private function curlGet($url, $referer = null, $headers = null)
{
$headers[] = 'Authorization: Basic ' . $this->access_token;
$headers[] = 'X-nl-user-id:' . $this->user_id;
$headers[] = 'X-nl-protocol-version: 1';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIEFILE, $this->cookieFile);
curl_setopt($ch, CURLOPT_COOKIEJAR, $this->cookieFile);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_USERAGENT, $this->useragent);
if(!is_null($referer)) curl_setopt($ch, CURLOPT_REFERER, $referer);
if(!is_null($headers)) curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
// curl_setopt($ch, CURLOPT_VERBOSE, true);
$html = curl_exec($ch);
if(curl_errno($ch) != 0)
{
throw new Exception("Error during GET of '$url': " . curl_error($ch));
}
$this->lastURL = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
$this->lastStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE);
return $html;
}
private function curlPost($url, $post_vars = '', $referer = null)
{
if (isset($this->access_token)) $headers[] = 'Authorization: Basic ' . $this->access_token;
if (isset($this->user_id)) $headers[] = 'X-nl-user-id:' . $this->user_id;
$headers[] = 'X-nl-protocol-version: 1';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIEFILE, $this->cookieFile);
curl_setopt($ch, CURLOPT_COOKIEJAR, $this->cookieFile);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_USERAGENT, $this->useragent);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_vars);
if(!is_null($headers)) curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
// curl_setopt($ch, CURLOPT_VERBOSE, true);
$html = curl_exec($ch);
$this->lastURL = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
$this->lastStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE);
return $html;
}
}
and is called with:
<?php
$new = $_GET['t'];
include_once('nest.php');
$nest = new Nest('usr', 'pwd');
$nest->temperature_set($new);
?>
If I replace $new with a number and then call the function it works but not in it current form. I have tried using the class to call outside variables, tried to just call but cant figure where and why its not working.
I suspect it is not working because your device is configured to use Celsius.
PHP is a dynamically typed language, as is JavaScript, but sometimes people forget that both will change types based on context (and sometimes the type conversion will have unexpected results).
All $_REQUEST variables are strings. Try changing:
$target_temp_celsius = $temp;
To
$target_temp_celsius = $temp + 0;
(JSON is strongly typed)

Airbnb Login Script through the command line using PHP

Is there a way to programmatically login to Airbnb with email/password through a CLI PHP script? and get a response back?
Thanks.
If you're looking to remotely log in to Airbnb and return information, you can use cURL to post data to Airbnb and return the results.
Examples on how to post form data can be found all over the web, however, a very reputable tutorial can be found here. Essentially, you want to cURL the login page, and include the login information with POST.
<?php
// A very simple PHP example that sends a HTTP POST to a remote site
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://www.airbnb.com/login");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,
"email=" . $email . "&password=" . $password);
// in real life you should use something like:
// curl_setopt($ch, CURLOPT_POSTFIELDS,
// http_build_query(array('email' => $email, 'password' => $password)));
// receive server response ...
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
curl_close ($ch);
// further processing ....
if ($server_output == "OK") { ... } else { ... }
?>
Make sure you check out this answer on SO, as well as the tutorials here.
Yes, there is. Airbnb's API isn't open to the general public, but if you sniff the traffic from your phone, you can see what requests are being sent to which endpoints. I experimented a little bit with their API and it follows as such for logging in
<?php
class AirBnB {
// Define the properties
public $currency = 'USD';
public $language = 'en';
public $country = 'us';
public $network = 'AT&T';
public $apiKey = '915pw2pnf4h1aiguhph5gc5b2';
public $adId = '911EBF1C-7C1D-46D5-A925-2F49ED064C92';
public $deviceId = 'a382581f36f1635a78f3d688bf0f99d85ec7e21f';
public function SendRequest($endpoint, $token, $post, $data, $cookies) {
$headers = array(
'Host: api.airbnb.com',
'Accept: application/json',
'Accept-Language: en-us',
'Connection: keep-alive',
'Content-Type: application/json',
'Proxy-Connection: keep-alive',
'X-Airbnb-Carrier-Country: '.$this->country,
'X-Airbnb-Currency: '.$this->currency,
'X-Airbnb-Locale: '.$this->language,
'X-Airbnb-Carrier-Name: '.$this->network,
'X-Airbnb-Network-Type: wifi',
'X-Airbnb-API-Key: '.$this->apiKey,
'X-Airbnb-Device-ID: '.$this->deviceId,
'X-Airbnb-Advertising-ID: '.$this->adId,
);
// Add the new custom headers
if($token) {
$header = 'X-Airbnb-OAuth-Token: '.$token;
array_push($headers, $header);
}
// Add the query string
if(!$post && is_array($data)) {
$endpoint .= '?'.http_build_query($data);
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.airbnb.com/'.$endpoint);
curl_setopt($ch, CURLOPT_USERAGENT, 'Airbnb/15.50 iPhone/9.2 Type/Phone');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
if($post) {
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
}
if($cookies) {
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookies.txt');
} else {
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookies.txt');
}
$response = curl_exec($ch);
$http = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
return array(
'http' => $http,
'response' => $response
);
}
public function Authorize($username, $password) {
$data = array(
'username' => $username,
'password' => $password,
'prevent_account_creation' => TRUE,
);
$data = $this->SendRequest('v1/authorize', FALSE, TRUE, $data, FALSE);
if($data['http'] == 200) {
$json = #json_decode($data['response'], TRUE);
return $json['access_token'];
} else {
return FALSE;
}
}
}
// Call a new instance of AirBnB
$airbnb = new AirBnB;
// Get the OAuth token
$token = $airbnb->Authorize('my#email.com', 'password');
?>
You can find out more about their API here.

Post JSON encoded and normal string data using CURL in PHP

I typically send an array of strings using CURL in PHP, something like this:
$data = array(
"key1" => $value,
"key2" => $value,
"key3" => $value,
"key4" => $value
);
Then, among other curl_setop settings, post using:
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
This all works fine. But now in addition to those strings, I have 1 dataset that is JSON encoded and I want to post it at the same time. JSON looks like this:
Array ( [ad_info] => {"MoPubAdUnitInteractions":"a","MoPubAdUnitConversations":"b","MoPubAdUnitGroups":"c"} )
I think I figured out how to do it by setting a header saying I'm going to be passing in JSON like this:
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
But then, can I simply add another line for the post, but in this case the JSON encoded value like this:
curl_setopt($curl, CURLOPT_POSTFIELDS, $json_data);
I'm kinda shooting in the dark, any suggestions on how I should be thinking about this?
Ok, here is the full example:
From Processing The Form Post:
$community_id = $_POST["communityid"];
$community_name = $_POST["communityname"];
$community_apns_name = $_POST["communityapnsname"];
$community_download_url = $_POST["communitydownloadurl"];
$community_open_tagging = $_POST["communityopentagging"];
$community_pull_content = $_POST["communitypullcontent"];
$community_push_content = $_POST["communitypushcontent"];
$community_ad_info = json_encode($_POST["ad_info"]);
$data = array(
"name" => $community_name,
"apns_name" => $community_apns_name,
"download_url" => $community_download_url,
"open_tagging" => $community_open_tagging,
"pull_content" => $community_pull_content,
"push_content" => $community_push_content,
);
$json_data = array("ad_info" => $community_ad_info);
$api_querystring = $gl_app_api_url . "communities";
$response = CallAPI('PATCH', $api_querystring, $data, $device_id = null, $community_id = null, $json_data);
And the Function in PHP I'm calling to do the CURL:
function CallAPI($method, $url, $data = false, $device_id = false, $community_id = false, $json_data = false) {
if (!$community_id) { // IF NO COMMUNITY ID IS PROVIDED
global $gl_community_id;
$community_id = $gl_community_id;
}
$curl = curl_init();
switch ($method)
{
case "POST":
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST');
if ($data)
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
break;
case "PUT":
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PUT');
if ($data)
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
break;
case "PATCH":
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PATCH');
if ($data)
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
break;
default:
if ($data)
$url = sprintf("%s?%s", $url, http_build_query($data));
}
// Optional Authentication:
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_USERPWD, "XXXX:XXXXX");
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
// Disable the SSL verificaiton process
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
if ($device_id)
curl_setopt($curl, CURLOPT_HTTPHEADER, array("device_id:" . $device_id));
if ($community_id)
curl_setopt($curl, CURLOPT_HTTPHEADER, array("X-Afty-Community:" . $community_id));
if ($json_data)
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($curl, CURLOPT_POSTFIELDS, $json_data);
// Confirm cURL gave a result, if not, write the error
$response = curl_exec($curl);
if ($response === FALSE) {
die("Curl Failed: " . curl_error($curl));
} else {
return $response;
}
}
Any help is greatly appreciated.
You use wrong approach. Setting CURLOPT_POSTFIELDS option twice doesn't lead to result you expected since each setting call discards effect of previous one.
Instead of this, you have to append extra data ($community_ad_info) to the main POST data ($data) before passing it to CURLOPT_POSTFIELDS option.
...
$community_ad_info = json_encode($_POST["ad_info"]);
$data = array(
"name" => $community_name,
"apns_name" => $community_apns_name,
"download_url" => $community_download_url,
"open_tagging" => $community_open_tagging,
"pull_content" => $community_pull_content,
"push_content" => $community_push_content,
"ad_info" => $community_ad_info
);
$response = CallAPI('PATCH', $api_querystring, $data, $device_id = null, $community_id = null);
...
This is untested of course but it should do what you need.
function CallAPI($method, $url, $data = false, $device_id = false, $community_id = false, $json_data = false) {
if (!$community_id) { // IF NO COMMUNITY ID IS PROVIDED
global $gl_community_id;
$community_id = $gl_community_id;
}
$curl = curl_init();
switch ($method)
{
case "POST":
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
if ($data)
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
break;
case "PUT":
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PUT');
if ($data)
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
break;
case "PATCH":
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PATCH');
if ($data)
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
break;
default:
if ($data)
$url = sprintf("%s?%s", $url, http_build_query($data));
}
// Optional Authentication:
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_USERPWD, "XXXX:XXXXX");
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
// Disable the SSL verificaiton process
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
if ($device_id)
curl_setopt($curl, CURLOPT_HTTPHEADER, array("device_id:" . $device_id));
if ($community_id)
curl_setopt($curl, CURLOPT_HTTPHEADER, array("X-Afty-Community:" . $community_id));
// Confirm cURL gave a result, if not, write the error
$response = curl_exec($curl);
if ($response === FALSE) {
die("Curl Failed: " . curl_error($curl));
} else {
return $response;
}
}
And now the actualy logic
$community_id = $_POST["communityid"];
$community_name = $_POST["communityname"];
$community_apns_name = $_POST["communityapnsname"];
$community_download_url = $_POST["communitydownloadurl"];
$community_open_tagging = $_POST["communityopentagging"];
$community_pull_content = $_POST["communitypullcontent"];
$community_push_content = $_POST["communitypushcontent"];
$community_ad_info = json_encode($_POST["ad_info"]);
$data = array(
"name" => $community_name,
"apns_name" => $community_apns_name,
"download_url" => $community_download_url,
"open_tagging" => $community_open_tagging,
"pull_content" => $community_pull_content,
"push_content" => $community_push_content,
"ad_info" => $community_ad_info
);
$api_querystring = $gl_app_api_url . "communities";
$response = CallAPI('PATCH', $api_querystring, $data, $device_id = null, $community_id = null);
The things to note here are,
the new content tyoe header tells it to be processed as a form post.
removal of the $json_data array, the "ad_info" key is not just added into the $data array
When you process this on the other side you can access the ad_info like this
$ad_info = json_decode($_POST['ad_info']);
You can access the other fields with
$apns_name = $_POST['apns_name'];

Categories