Friday, 15 July 2011

I get {"error":"unauthorized"} when trying to run .php file on Apache server -



I get {"error":"unauthorized"} when trying to run .php file on Apache server -

php file need run on localhost server. have downloaded mamp , changed apache port 80. added file htdocs folder , when run server , go localhost can see .php file in list. when click on next error: {"error":"unauthorized"} , nil else. im using file ios app , need know can access file via localhost adress. im new php if help grateful. thanks.

the code:

<?php header('content-type:application/json'); $appid = $_post['appid']; $restapi = $_post['restapi']; $alert = $_post['alert']; $channels = str_replace(' ', '', $_post['channels']); $channels = explode(",",$channels); $url = 'https://api.parse.com/1/push'; $data = json_encode( array( 'channels' => $channels, 'type' => 'ios', 'data' => array( 'alert' => $alert, 'sound' => 'push.caf', 'badge' => 'increment' ) ),true ); $curl = curl_init(); $curlarray = array( curlopt_post => true, curlopt_postfields => $data, curlopt_returntransfer => true, curlopt_header => false, curlopt_encoding => "gzip", curlopt_httpheader => array( 'x-parse-application-id: ' . $appid, 'x-parse-rest-api-key: ' . $restapi, 'content-type: application/json', 'content-length: ' . strlen($data), ), curlopt_url => $url ); curl_setopt_array($curl, $curlarray); $response = curl_exec($curl); $code = curl_getinfo($curl, curlinfo_http_code); curl_close($curl); echo $response; ?>

php apache localhost mamp

No comments:

Post a Comment