MYSQL Error while inserting header value in DB - php

I am trying to insert header value of an email into DB but I am getting below mentioned error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'color:#1F497D'> =
while variable which holds this value is :
$headerValue="x-store-info: J++/JTCzmObr++wNraA4Pa4f5Xd6uensVd8mvt5QRSOLhsGzuy+tUtmSAtwbT+Lhg32fI7JkT4T+oCCjUH2Po9WkZAzmMIYU0MxTJOx1JRLfrWSAJ4yq+QDUHkUMkOR6HLEpJj1jCGc=
Authentication-Results: hotmail.com; spf=neutral (sender IP is 66.39.4.58) smtp.mailfrom=xyz.abh#abc.in; dkim=none header.d=abc.in; x-hmca=none header.id=xyz.abh#abc.in
X-SID-PRA: xyz.abh#abc.in
X-AUTH-Result: NONE
X-SID-Result: NONE
X-Message-Status: n:n
X-Message-Delivery: Vj0xLjE7dXM9MDtsPTE7YT0xO0Q9MTtHRD0xO1NDTD0x
X-Message-Info: NhFq/7gR1vQP6lZqH93tpVQFT69R+Bmv3UykwdELmYZ7B3Xiq5XoKqM5Sg6LjXxhKff4sob+93uheSiXVqp/rY0haPrEn6zvVhDahXaFE0nw9nQNG7DoZ7tXJdlzLLUsiyHtmFWhLupgJOiCWx/N3LIzuBcoyXRyO+0UqhjFaJY+pNdDEFGjgVOsdbFgKDHkJCilkjEyMXrCtfvi6LQwqpvJ18a+yny6
Received: from mail1.g9.pair.com ([66.39.4.58]) by BAY0-MC2-F25.Bay0.hotmail.com with Microsoft SMTPSVC(6.0.3790.4900);Sun, 9 Mar 2014 10:21:21 -0700
Received: from abccto (unknown [182.71.149.242])by mail1.g9.pair.com (Postfix) with ESMTPSA id 447B739863for <outloo1#outlook.com>; Sun, 9 Mar 2014 13:21:18 -0400 (EDT)
From: "xyz t" <xyz.dps#abc.in>
To: <outloo1#outlook.com>
Subject: This is test 1
Date: Sun, 9 Mar 2014 22:51:15 +0530
Message-ID: <001701cf3bbb$fc5a1940$f50e4bc0$#abc.in>
MIME-Version: 1.0
Content-Type: multipart/alternative;boundary="----=_NextPart_000_0018_01CF3BEA.16125540"
X-Mailer: Microsoft Office Outlook 12.0
Thread-Index: Ac87u+X0jencwqnORxOvsW8e4oF0PQAAAYbQ
Content-Language: en-us
Return-Path: xyzt#abc.in
X-OriginalArrivalTime: 09 Mar 2014 17:21:21.0782 (UTC) FILETIME=[FDAB5160:01CF3BBB]
This is a multi-part message in MIME format.
------=_NextPart_000_0018_01CF3BEA.16125540
Content-Type: text/plain;charset="us-ascii"
Content-Transfer-Encoding: 7bit
Hi Freind
------=_NextPart_000_0018_01CF3BEA.16125540
Content-Type: text/html;charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
<html xmlns:v=3D"urn:schemas-microsoft-com:vml" =
xmlns:o=3D"urn:schemas-microsoft-com:office:office" =
xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" =
xmlns=3D"http://www.w3.org/TR/REC-html40"><head><META =
HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Dus-ascii"><meta name=3DGenerator content=3D"Microsoft Word 12 =
(filtered medium)"><style><!--
/* Font Definitions */
#font-face{font-family:"Cambria Math";panose-1:2 4 5 3 5 4 6 3 2 4;}
#font-face{font-family:Calibri;panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal{margin:0in;margin-bottom:.0001pt;font-size:11.0pt;font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink{mso-style-priority:99;color:blue;text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed{mso-style-priority:99;color:purple;text-decoration:underline;}
span.EmailStyle17{mso-style-type:personal;font-family:"Calibri","sans-serif";color:windowtext;}
span.EmailStyle18{mso-style-type:personal-reply;font-family:"Calibri","sans-serif";color:#1F497D;}
.MsoChpDefault{mso-style-type:export-only;font-size:10.0pt;}
#page WordSection1{size:8.5in 11.0in;margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]--></head><body lang=3DEN-US link=3Dblue =
vlink=3Dpurple><div class=3DWordSection1><p =
class=3DMsoNormal><o:p> </o:p></p><p class=3DMsoNormal>Hi =
xyz<span style=3D'color:#1F497D'> =
</span><o:p></o:p></p></div></body></html>
------=_NextPart_000_0018_01CF3BEA.16125540--"
I had obtained this value by applying :
$header = preg_replace('~[\r\n]+[ \t]+~', null, $obj_thang);
$header = preg_replace('~[ \t]+~', ' ', $header);

1. string mysql_real_escape_string ( string $unescaped_string [, resource $link_identifier = NULL ] )
2. Escapes special characters in the unescaped_string, taking into
account the current character set of the connection so that it is
safe to place it in a mysql_query(). If binary data is to be
inserted, this function must be used.
3. mysql_real_escape_string() calls MySQL's library function
mysql_real_escape_string, which prepends backslashes to the
following characters: \x00, \n, \r, \, ', " and \x1a.
4. This function must always (with few exceptions) be used to make data
safe before sending a query to MySQL.
Further details are at -:
http://in3.php.net/mysql_real_escape_string

Related

Parsing PHP with fopen() encoding issue

I'm having issues parsing a csv file in php, using fopen() taking in API data.
My code works when I use a URL that displays the csv file in the browser as stated in 1) below. But I get random characters outputted from a URL that ends in format=csv as seen in 2) below.
1) Working URL: Returned expected values
https://www.kimonolabs.com/api/csv/duo2mkw2?apikey=yjEl780lSQ8IcVHkItiHzzUZxd1wqSJv
2) Not Working URL: Returns random characters
https://www.parsehub.com/api/v2/projects/tM9MwgKrh0c4b81WDT_4FkaC/last_ready_run/data?api_key=tD3djFMGmyWmDUdcgmBVFCd3&format=csv
Here is my code: - using URL (2) above
<?php
$f_pointer=fopen("https://www.parsehub.com/api/v2/projects/tM9MwgKrh0c4b81WDT_4FkaC/ last_ready_run/data?api_key=tD3djFMGmyWmDUdcgmBVFCd3&format=csv","r");
while(! feof($f_pointer)){
$ar=fgetcsv($f_pointer);
echo $ar[1];
echo "<br>";
}
?>
Output: For URL mentioned in (2) above:
root#MorryServer:/# php testing.php
?IU?Q?JL?.?/Q?R??/)?J-.?))VH?/OM?K-NI?T0?P?*ͩT0204jzԴ?H???X???# D??K
Correct Output: If I use URL Type as stated in (1)
root#MorryServer:/# php testing.php
PHP Notice: Undefined offset: 1 in /testing.php on line 24
jackpot€2,893,210
This is an encoding problem.
The given file contains UTF-8 chars. These are read by the fgetcsv function, which is binary safe. Line Endings are Unix-Format ("\n").
The output on the terminal is scrumbled. Looking at the headers sent, we see:
GET https://www.parsehub.com/api/v2/projects/tM9MwgKrh0c4b81WDT_4FkaC/last_ready_run/data?api_key=tD3djFMGmyWmDUdcgmBVFCd3&format=csv --> 200 OK
Connection: close
Date: Sat, 11 Jul 2015 13:15:24 GMT
Server: nginx/1.6.2
Content-Encoding: gzip
Content-Length: 123
Content-Type: text/csv; charset=UTF-8
Last-Modified: Fri, 10 Jul 2015 11:43:49 GMT
Client-Date: Sat, 11 Jul 2015 13:15:23 GMT
Client-Peer: 107.170.197.156:443
Client-Response-Num: 1
Client-SSL-Cert-Issuer: /C=GB/ST=Greater Manchester/L=Salford/O=COMODO CA Limited/CN=COMODO RSA Domain Validation Secure Server CA
Client-SSL-Cert-Subject: /OU=Domain Control Validated/OU=PositiveSSL/CN=www.parsehub.com
Mind the Content-Encoding: gzip: fgetcsv working on an URL doesn't obviously handle gzip encosing. The scrumbled String is just the gzipped content of the "file".
Look at the gzip lib of PHP to first deflate that before parsing it.
Proof:
srv:~ # lwp-download 'https://www.parsehub.com/api/v2/projects/tM9MwgKrh0c4b81WDT_4FkaC/last_ready_run/data?api_key=tD3djFMGmyWmDUdcgmBVFCd3&format=csv' data
123 bytes received
srv:~ # file data
data: gzip compressed data, was "tcW80-EcI6Oj2TYPXI-47XwK.csv", from Unix, last modified: Fri Jul 10 11:43:48 2015, max compression
srv:~ # gzip -d < data
"title","jackpot"
"Lotto Results for Wednesday 08 July 2015","€2,893,210"
To get the proper output, minimal changes are need: Just add a stream wrapper:
<?php
$f_pointer=fopen("compress.zlib://https://www.parsehub.com/api/v2/projects/tM9MwgKrh0c4b81WDT_4FkaC/last_ready_run/data?api_key=tD3djFMGmyWmDUdcgmBVFCd3&format=csv","r");
if ( $f_pointer === false )
die ("invalid URL");
$ar = array();
while(! feof($f_pointer)){
$ar[]=fgetcsv($f_pointer);
}
print_r($ar);
?>
Outputs:
Array
(
[0] => Array
(
[0] => title
[1] => jackpot
)
[1] => Array
(
[0] => Lotto Results for Wednesday 08 July 2015
[1] => €2,893,210
)
)

PHP: Need to find certain data from a string

$string = "Response 22: 404 (8345ms), headers: Accept-Ranges=bytes,
Cache-Control=no-cache, no-store, private, Connection=close,
Content-Encoding=gzip, Content-Language=it-it, Content-Length=1674,
Content-Location=index.html.it-it, Content-Type=text/html;
charset=utf-8, Date=Wed, 24 Sep 2014 19:01:30 GMT,
ETag='eb1-50331586750c0;503ac178f62dd', Last-Modified=Tue, 16 Sep 2014
16:35:55 GMT, Server=Apache,
Strict-Transport-Security=max-age=31536000; includeSubDomains,
TCN=choice, Vary=negotiate,accept,accept-language,Accept-Encoding,
X-Frame-Options=SAMEORIGIN, X-UA-Compatible=IE=Edge";
Here I want to grab response number(=> 22), response code(=> 404) and its milli seconds(=> 8345ms).
I think I have to use regex, but I am new to that. Can you please give any suggestions?
Response\s*(\d+):\s*(\d+)\s*\((\S+)?\)
Try this.Get the three groups.See demo.
http://regex101.com/r/qC9cH4/3

Problems with regexes when porting from Ruby to PHP

I have two bits of code that seem to be correct translations of one another. They unfortunately appear to return different values.
Code in Ruby:
def separate(text,boundary = nil)
# returns array of strings and arrays containing all of the parts of the email
textList = []
if !boundary #look in the email for "boundary= X"
text.scan(/(?<=boundary=).*/) do |bound|
textList = recursiveSplit(text,bound)
end
end
if boundary
textList = recursiveSplit(text,boundary)
end
puts textList.count
return textList
end
def recursiveSplit(chunk,boundary)
if chunk.is_a? String
searchString = "--" + boundary
ar = chunk.split(searchString)
return ar
elsif chunk.is_a? Array
chunk do |bit|
recursiveSplit(bit,boundary);
end
end
end
Code in PHP:
function separate($text, $boundary="none"){
#returns array of strings and arrays containing all the parts of the email
$textBlock = [];
if ($boundary == "none") {
preg_match_all('/(?<=boundary=).*/', $text, $matches);
$matches = $matches[0];
foreach ($matches as $match) {
$textList = recursiveSplit($text,$match);
}
}else {
$textList = recursiveSplit(text,boundary);
}
var_dump($textList);
return$textList;
}
function recursiveSplit($chunk,$boundary){
if (is_string($chunk)) {
$ar = preg_split("/--".$boundary."/", $chunk);
//$ar = explode($searchString, $chunk);
return $ar;
}
elseif (is_array($chunk)) {
foreach ($chunk as $bit) {
recursiveSplit($bit,$boundary);
}
}
}
var_dump($textList) shows an array of length 3, whereas textList.count => 4. What gives?
Anonymized $text example:
MIME-Version: 1.0
Received: by 10.112.170.40 with HTTP; Fri, 3 May 2013 05:08:21 -0700 (PDT)
Date: Fri, 3 May 2013 08:08:21 -0400
Delivered-To: me#gmail.com
Message-ID: <CADPp44E47syuXvP1K-aemhcU7vdSijZkfKLu-74QPWs9U9551Q#mail.gmail.com>
Subject: MiB 5/3/13 7:43AM (EST)
From: Me <me#gmail.com>
To: Someone <someone#aol.com>
Content-Type: multipart/mixed; boundary=BNDRY1
--BNDRY1
Content-Type: multipart/alternative; boundary=BNDRY2
--BNDRY2
Content-Type: text/plain; charset=ISO-8859-1
-TEXT STUFF HERE. SAYING THINGS
ABOUT CERTAIN THINGS
--BNDRY2
Content-Type: text/html; charset=ISO-8859-1
<div dir="ltr">-changed signature methods to conform more to working clinic header methods(please test/not testable in simulator)<div style>-confirmed that signature image is showing up in simulator. Awaiting further tests</div>
<div style>-Modified findings spacing/buffer. See if you like it</div></div>
--BNDRY2--
--BNDRY1
Content-Type: application/zip; name="Make it Brief.ipa.zip"
Content-Disposition: attachment; filename="Make it Brief.ipa.zip"
Content-Transfer-Encoding: base64
X-Attachment-Id: f_hg9biuno0
<<FILE DATA>>
--BNDRY1--
Run separate(text) on example or any gmail "view original" email in order to reproduce error
BINGO ZINGO Figured it out!
Apparently, in PHP, in order to change a variable inside a loop involving that variable, you have to preface the variable with '&'
Added '&' and fixed some general recursion errors and it ran smoothly.

fullCalendar "events: 'somepage.php'" JSON Results not displaying

I am trying to get the events for my fullCalendar implementation with the "events (as a JSON feed)" built in feature.
...
event: 'calendarFill.php',
...
The php file returns the following JSON data:
[{"id":"40","title":"test four","services":"Reflexology (40), foot-soak","start":"Tue Mar 26 2013 13:00:00","end":"Tue Mar 26 2013 13:40:00","color":"#e56b15","customerId":"21","phone":"555-0404","email":"test4","notes":"test two of update. this sentence added at update.","seat":"Side Couch 9","vip":"yes","confirmed":"yes","knows_policies":"yes","customer_here":"0","allDay":"false"},{"id":"41","title":"test four","services":"Foot-Soak, ","start":"Wed Mar 27 2013 19:00:00","end":"Wed Mar 27 2013 19:15:00","color":"#e56b15","customerId":"21","phone":"555-0404","email":"test4","notes":"test of addslashes. what's going to happen?","seat":"Front Chair 2","vip":"yes","confirmed":"yes","knows_policies":"yes","customer_here":"0","allDay":"false"}]
The above does not work - the events are not displayed on the calendar. I've cut and pasted the code directory in my Javascript code:
events: {"id":"40","title":"test four","services":"Reflexology (40), foot-soak","start":"Tue Mar 26 2013 13:00:00","end":"Tue Mar 26 2013 13:40:00","color":"#e56b15","customerId":"21","phone":"555-0404","email":"test4","notes":"test two of update. this sentence added at update.","seat":"Side Couch 9","vip":"yes","confirmed":"yes","knows_policies":"yes","customer_here":"0","allDay":"false"},{"id":"41","title":"test four","services":"Foot-Soak, ","start":"Wed Mar 27 2013 19:00:00","end":"Wed Mar 27 2013 19:15:00","color":"#e56b15","customerId":"21","phone":"555-0404","email":"test4","notes":"test of addslashes. what's going to happen?","seat":"Front Chair 2","vip":"yes","confirmed":"yes","knows_policies":"yes","customer_here":"0","allDay":"false"}],
And, it does not display. But, if I edit the above to remove all the quotes that are not surrounding text values (as below), IT WORKS.
events: [{id:40,title:"test four",services:"Reflexology (40), foot-soak",start:"Tue Mar 26 2013 13:00:00",end:"Tue Mar 26 2013 13:40:00",color:"#e56b15",customerId:21,phone:"555-0404",email:"test4",notes:"test two of update. this sentence added at update.",seat:"Side Couch 9",vip:"yes",confirmed:"yes",knows_policies:"yes",customer_here:0,allDay:false},{id:41,title:"test four",services:"Foot-Soak, ",start:"Wed Mar 27 2013 19:00:00",end:"Wed Mar 27 2013 19:15:00",color:"#e56b15",customerId:21,phone:"555-0404",email:"test4",notes:"test of addslashes. what's going to happen?",seat:"Front Chair 2",vip:"yes",confirmed:"yes",knows_policies:"yes",customer_here:0,allDay:false}],
I am using the documentation at this link: http://arshaw.com/fullcalendar/docs/event_data/events_json_feed/
What am I doing wrong? Should I remove the 'json_encode' from my php and just return a string formatted like the above? I'd like to do it the 'right' way and not some work-around.
Added the php as requested:
// for connection to db
include("../includes/config.php");
include("../includes/mysql_functions.php");
// connection with db
$linkID = db_connect();
$returnValue = array();
$getEventData = mysql_query("SELECT apt_num, services, apt_date_start, apt_date_end, therapist, customer_num, notes, seat, confirmed, knows_policies, here FROM appointments", $linkID);
if ($getEventData != FALSE && mysql_num_rows($getEventData) > 0)
{
while ($theEventData = mysql_fetch_array($getEventData))
{
$getCustomerString = "SELECT first_name, middle_name, last_name, phone, email, vip FROM customer WHERE customer_num = ".$theEventData['customer_num'];
$getCustomerData = mysql_query($getCustomerString, $linkID);
if ($getCustomerData != FALSE && mysql_num_rows($getCustomerData) > 0)
{
while($theCustomerData = mysql_fetch_array($getCustomerData))
{
$customerName = $theCustomerData['first_name']." ".$theCustomerData['middle_name']." ".$theCustomerData['last_name'];
$customerPhone = $theCustomerData['phone'];
$customerEmail = $theCustomerData['email'];
$customerVip = $theCustomerData['vip'];
}
}
else
{
$customerName = "error";
$customerPhone = "error";
$customerEmail = "error";
$customerVip = "error";
}
$rowArray['id'] = $theEventData['apt_num'];
$rowArray['title'] = $customerName;
$rowArray['services'] = $theEventData['services'];
$rowArray['start'] = date("D", $theEventData['apt_date_start'])." ".date("M", $theEventData['apt_date_start'])." ".date("d", $theEventData['apt_date_start'])." ".date("Y", $theEventData['apt_date_start'])." ".date("H", $theEventData['apt_date_start']).":".date("i", $theEventData['apt_date_start']).":".date("s", $theEventData['apt_date_start']);
$rowArray['end'] = date("D", $theEventData['apt_date_end'])." ".date("M", $theEventData['apt_date_end'])." ".date("d", $theEventData['apt_date_end'])." ".date("Y", $theEventData['apt_date_end'])." ".date("H", $theEventData['apt_date_end']).":".date("i", $theEventData['apt_date_end']).":".date("s", $theEventData['apt_date_end']);
$rowArray['color'] = $theEventData['therapist'];
$rowArray['customerId'] = $theEventData['customer_num'];
$rowArray['phone'] = $customerPhone;
$rowArray['email'] = $customerEmail;
$rowArray['notes'] = $theEventData['notes'];
$rowArray['seat'] = $theEventData['seat'];
$rowArray['vip'] = $customerVip;
$rowArray['confirmed'] = $theEventData['confirmed'];
$rowArray['knows_policies'] = $theEventData['knows_policies'];
$rowArray['customer_here'] = $theEventData['here'];
$rowArray['allDay'] = "false";
array_push($returnValue, $rowArray);
}
}
else
{
$returnValue[0] = "error";
}
print json_encode($returnValue);
Markus Vetter (from Google+) found the problem. In the original code returned from my php file there is an "'" that causes an issue. I needed to 'addslashes' to my php before returning it to the jQuery/Javascript. Once that was done, the jQuery / fullCalendar code was able to render my events as expected.
A second pair of eyes does wonders! Thank you Markus Vetter!
The original code returned:
[{"id":"40","title":"test four","services":"Reflexology (40), foot-soak","start":"Tue Mar 26 2013 13:00:00","end":"Tue Mar 26 2013 13:40:00","color":"#e56b15","customerId":"21","phone":"555-0404","email":"test4","notes":"test two of update. this sentence added at update.","seat":"Side Couch 9","vip":"yes","confirmed":"yes","knows_policies":"yes","customer_here":"0","allDay":"false"},{"id":"41","title":"test four","services":"Foot-Soak, ","start":"Wed Mar 27 2013 19:00:00","end":"Wed Mar 27 2013 19:15:00","color":"#e56b15","customerId":"21","phone":"555-0404","email":"test4","notes":"test of addslashes. what's going to happen?","seat":"Front Chair 2","vip":"yes","confirmed":"yes","knows_policies":"yes","customer_here":"0","allDay":"false"}]
After using 'addslashes' in my php for all text fields:
[{"id":"40","title":"test four","services":"Reflexology (40), foot-soak","start":"Tue Mar 26 2013 13:00:00","end":"Tue Mar 26 2013 13:40:00","color":"#e56b15","customerId":"21","phone":"555-0404","email":"test4","notes":"test two of update. this sentence added at update.","seat":"Side Couch 9","vip":"yes","confirmed":"yes","knows_policies":"yes","customer_here":"0","allDay":"false"},{"id":"41","title":"test four","services":"Foot-Soak, ","start":"Wed Mar 27 2013 19:00:00","end":"Wed Mar 27 2013 19:15:00","color":"#e56b15","customerId":"21","phone":"555-0404","email":"test4","notes":"test of addslashes. what\'s going to happen?","seat":"Front Chair 2","vip":"yes","confirmed":"yes","knows_policies":"yes","customer_here":"0","allDay":"false"}]
Actually solved this time! In my php file, the last value added to the $rowArray is: $rowArray['allDay'] = "false". Instead of being a text value, it needs to be the actual boolean value. This "$rowArray['allDay'] = false" fixed the problem.
I had the same issue and it was a formatting thing for me as well.
This is how my json is returning now and it is finally working.
[{"title":"Coke Trade Show","start":"2014-12-03"},{"title":"Michigan Show","start":"2014-12-04"}]
Definitely a good idea to paste your json return straight into the JS to make sure it is working.

json_decode PHP bugged ? same Json works in other languages

Well this JSON I have doesn't work on PHP Json_decode, it returns NULL, and when I place the exact JSON in the website http://jsonformatter.curiousconcept.com/#jsonformatter
it says its valid and it works just fine.
$json = <<<START
{"currentUserScreenName":"tatXtxt","recentPlaces":[],"cdnBase":{"versioned":{"ssl":["https:\/\/si0.twimg.com\/a\/1309465578"],"http":["http:\/\/a0.twimg.com\/a\/1309465578","http:\/\/a1.twimg.com\/a\/1309465578","http:\/\/a2.twimg.com\/a\/1309465578","http:\/\/a3.twimg.com\/a\/1309465578"]},"unversioned":{"ssl":["https:\/\/si0.twimg.com"],"http":["http:\/\/a0.twimg.com","http:\/\/a1.twimg.com","http:\/\/a2.twimg.com","http:\/\/a3.twimg.com"]}},"pageLocaleJS":"http:\/\/a3.twimg.com\/a\/1309465578\/javascripts\/phoenix\/i18n\/pt.js","becameUser":false,"payload":{"profiling":false,"conditionalTemplates":{}},"isNarrow":true,"deciderFeatures":{"tweet_stream_list":1,"geo_location":1,"people_stream_friends":1,"tweet_stream_favorites":1,"promo_component":1,"phoenix_local_gowalla":1,"new_trends_location_selector":1,"geo_ui":1,"flock":1,"phoenix_geo_v4":1,"geo_ui_dropdown_available":1,"tweet_stream_mentions_polling":1,"contact_import_stream":1,"html5Routing":1,"list_stream_memberships":1,"phoenix_frontpage_rotate_avatars":1,"tweet_stream_retweets_by_you":1,"inline_media_component":1,"whotofollow_random_sample":1,"phoenix_sandboxed_ajax":1,"tweet_stream_following_polling":1,"whotofollow_recommendations":1,"phoenix_first_time":1,"list_stream_own_lists":1,"phoenix_facets_logged_out":1,"phoenix_amazon_details":1,"in_reply_to_component":1,"sync_scribe":1,"geo_show_similar_places":1,"phoenix_turkey_permalink":1,"tweet_streams_polling":1,"media_flagging":1,"phoenix_search_relevance_logged_out":1,"user_shuffler":1,"mobile_download_gallery_logged_out":1,"phoenix_aol_video":1,"logged_out_people_search":1,"social_context":1,"email_device_settings":1,"people_streams":1,"tweet_stream_user_polling":1,"tweet_stream_retweets_by_you_polling":1,"people_stream_people_search":1,"phoenix_local_plancast":1,"scribe_client_event":1,"tweet_streams":1,"profile_combined_api":1,"tweet_stream_user":1,"phoenix_facets_videos":1,"phoenix_instagram_and_friends":1,"tweet_geo_component":1,"tweet_stream_mentions":1,"phoenix_tweetbox_talon":1,"phoenix_scribe":1,"phoenix_local_meetup":1,"tweet_stream_search":1,"phoenix_facets":1,"dashboard_activity_following":1,"retweeters_component":1,"people_stream_list_followers":1,"more_lists_component":1,"mt_tweet_backend_bing":1,"phoenix_talon_on_copy":1,"place_users_stream":1,"message_stream":1,"tweet_stream_home":1,"phoenix_autocomplete_place_trigger_words":1,"dashboard_activity_favorites":1,"dashboard_activity_listed":1,"list_streams":1,"tweet_stream_your_tweets_retweeted_polling":1,"phoenix_local_foursquare":1,"phoenix_puffin":1,"tweet_stream_list_polling":1,"tweet_stream_retweets_by_others":1,"phoenix_search_dropdown":1,"people_stream_follower_requests":1,"tweet_stream_home_polling":1,"trends_component":1,"phoenix_search_relevance":1,"tweet_stream_your_tweets_retweeted":1,"phoenix_pretty_links":1,"local_trends":1,"place_people_component":1,"people_stream_list_members":1,"place_tweets_component":1,"dashboard_activity_followers":1,"following_page_tweets_tab":1,"list_stream_subscriptions":1,"tweet_stream_retweets_by_others_polling":1,"mobile_download_gallery":1,"geo_more_places":1,"japanese_ad_component":1,"infinite_scroll":1,"tweet_stream_search_polling":1,"whotofollow_similarities":1,"people_stream_followers":1,"recent_tweets_component":1,"tweet_stream_favorites_polling":1,"welcome_warm_signup":1,"geo_allow_set_location_manually":1,"promptbird_phoenix":1,"phoenix_facets_images":1,"promoted_accounts_in_whotofollow_viewall":1,"suggestion_categories_streams":1,"geo_place_creation":1,"conversations":1,"tweet_stream_following":1,"phoenix_autocomplete":1,"onebox_user_search":1,"advanced_search":1,"i18n_new_translation_center":1,"fake_loggedout_decider":1,"newest_list_members_component":1},"adminRights":false,"isPreflight":false,"languages":[{"css_classes":"western pt","name":"Portugu\u00eas","code":"pt","name_en":"Portuguese"},{"css_classes":"western it","name":"Italiano","code":"it","name_en":"Italian"},{"css_classes":"western es","name":"Espa\u00f1ol","code":"es","name_en":"Spanish"},{"css_classes":"western tr","name":"T\u00fcrk\u00e7e","code":"tr","name_en":"Turkish"},{"css_classes":null,"name":"English","code":"en","name_en":"English"},{"css_classes":"asian ko","name":"\ud55c\uad6d\uc5b4","code":"ko","name_en":"Korean"},{"css_classes":"western fr","name":"fran\u00e7ais","code":"fr","name_en":"French"},{"css_classes":"western ru","name":"\u0420\u0443\u0441\u0441\u043a\u0438\u0439","code":"ru","name_en":"Russian"},{"css_classes":"western de","name":"Deutsch","code":"de","name_en":"German"},{"css_classes":"asian ja","name":"\u65e5\u672c\u8a9e","code":"ja","name_en":"Japanese"}],"abBuckets":{"remember_me_on_signup_83":{"bucket":"experiment","version":9,"experiment_key":"remember_me_on_signup_83","bucket_names":["control","experiment"]},"Contact_Import_Images-40":{"bucket":"control","version":3,"experiment_key":"Contact_Import_Images-40","bucket_names":["control","images"]},"Contact_Import_Services-39":{"bucket":"control","version":4,"experiment_key":"Contact_Import_Services-39","bucket_names":["control","vertical","vertical_matched"]},"welcome_flow_addressbook_81":{"bucket":"control","version":8,"experiment_key":"welcome_flow_addressbook_81","bucket_names":["control","addressbook"]},"Relevance_V1-49":{"bucket":"control","version":10,"experiment_key":"Relevance_V1-49","bucket_names":["control","recent"]}},"pageLocaleClass":"western pt","pageLocale":"pt","globalConfig":{"photo_sizes":{"large":{"h":2048,"resize":"fit","w":1024},"medium":{"h":1200,"resize":"fit","w":600},"thumb":{"h":150,"resize":"crop","w":150},"small":{"h":480,"resize":"fit","w":340}},"non_username_paths":["about","account","accounts","activity","all","announcements","anywhere","api_rules","api_terms","apirules","apps","auth","badges","blog","business","buttons","contacts","devices","direct_messages","download","downloads","edit_announcements","faq","favorites","find_sources","find_users","followers","following","friend_request","friendrequest","friends","goodies","help","home","im_account","inbox","invitations","invite","jobs","list","login","logout","me","mentions","messages","newtwitter","notifications","nudge","oauth","phoenix_search","positions","privacy","public_timeline","related_tweets","replies","retweeted_of_mine","retweets","retweets_by_others","rules","saved_searches","search","sent","settings","share","signup","signin","similar_to","statistics","terms","tos","translate","trends","tweetbutton","twttr","update_discoverability","users","welcome","who_to_follow","widgets","zendesk_auth","media_signup","phoenix_qunit_tests"],"max_media_per_upload":1,"short_url_length_https":20,"characters_reserved_per_media":20,"photo_size_limit":3145728,"short_url_length":19},"requestCacheSeedData":[{"options":[{}],"json":{"profile_sidebar_border_color":"C0DEED","profile_background_tile":false,"profile_sidebar_fill_color":"DDEEF6","name":"Testando","created_at":"Fri Jul 01 11:10:49 +0000 2011","location":null,"profile_image_url":"http:\/\/a1.twimg.com\/sticky\/default_profile_images\/default_profile_2_normal.png","is_translator":false,"profile_link_color":"0084B4","id_str":"327319701","follow_request_sent":false,"contributors_enabled":false,"favourites_count":0,"states":{"pending_email":"testandoXXXX#hotmail.com","bouncing_email":["testandoXXXX#hotmail.com"],"detached_email":false,"suspended":false,"needs_employee_email_update":false},"url":null,"default_profile":true,"id":327319701,"utc_offset":null,"profile_image_url_https":"https:\/\/si0.twimg.com\/sticky\/default_profile_images\/default_profile_2_normal.png","profile_use_background_image":true,"listed_count":0,"lang":"pt","followers_count":0,"profile_text_color":"333333","protected":false,"profile_background_color":"C0DEED","profile_background_image_url_https":"https:\/\/si0.twimg.com\/images\/themes\/theme1\/bg.png","verified":false,"time_zone":null,"geo_enabled":false,"description":null,"notifications":false,"statuses_count":0,"default_profile_image":true,"friends_count":0,"profile_background_image_url":"http:\/\/a0.twimg.com\/images\/themes\/theme1\/bg.png","show_all_inline_media":false,"following":false,"screen_name":"tatXtxt"},"api_request_name":"account\/verify_credentials"},{"options":[{"include_available_features":1,"include_entities":1,"pc":true,"contributor_details":true}],"json":[],"api_request_name":"statuses\/home_timeline"},{"options":[{}],"json":{"sleep_time":{"end_time":null,"enabled":false,"start_time":null},"language":"pt","discoverable_by_email":true,"always_use_https":false,"geo_enabled":false},"api_request_name":"account\/settings"},{"options":[{"pc":true}],"json":{"trends":{"current_trends":[{"name":"#listentoyourheart","url":"http:\/\/search.twitter.com\/search?q=%23listentoyourheart"},{"name":"#youneedtositdown","url":"http:\/\/search.twitter.com\/search?q=%23youneedtositdown"},{"name":"Teddy Bautista","url":"http:\/\/search.twitter.com\/search?q=%22Teddy%20Bautista%22"},{"name":"#eqakl","url":"http:\/\/search.twitter.com\/search?q=%23eqakl"},{"name":"Mayor Duterte","url":"http:\/\/search.twitter.com\/search?q=%22Mayor%20Duterte%22"},{"name":"Brendon Urie","url":"http:\/\/search.twitter.com\/search?q=%22Brendon%20Urie%22"},{"name":"Mirror Mirror","url":"http:\/\/search.twitter.com\/search?q=%22Mirror%20Mirror%22"},{"name":"BTD","url":"http:\/\/search.twitter.com\/search?q=BTD"},{"name":"'Perfect Night'","url":"http:\/\/search.twitter.com\/search?q=%22'Perfect%20Night'%22"},{"name":"Black & White","url":"http:\/\/search.twitter.com\/search?q=%22Black%20&%20White%22"}]}},"api_request_name":"trends\/current"},{"options":[{}],"json":{"promo":{"name":"IOC Olympic Day (PT)","created_at":"Wed Jun 22 21:28:29 +0000 2011","promo_contents":"\u003Ca href=\"http:\/\/contest.olympic.org\/\" class=\"definition\" onClick=\"javascript: pageTracker._trackPageview('\/\ndefinition\/IOC_pt');\"\u003E\u003Cstrong\u003EDia Ol\u00edmpico no Twitter\u003C\/strong\u003E\u003C\/a\u003E Comemore o espir\u00edto dos Jogos Ol\u00edmpicos no Twitter e voc\u00ea poder\u00e1 ganhar uma viagem a Londres 2012.","promo_type":"","updated_at":"Thu Jun 23 17:00:45 +0000 2011","id":150,"is_sponsored":false,"is_active":true,"locale":"pt"}},"api_request_name":"promos\/random"}],"remoteIP":"189.104.75.181","appcacheRequiredMajorVersion":1,"userProperties":{"emailDiscoverabilitySet":true,"mobilePhoneDiscoverabilitySet":false,"deviceAddress":null,"discoverableByEmail":true,"discoverableByMobilePhone":false,"emailAddress":"null","deviceSetup":false},"currentUser":{"memberships_path":"\/tatXtxt\/lists\/memberships","rgba_tweet_border_color":"rgba(0,132,180,0.15)","linkified_status":"","rgba_sidebar_color":"rgba(221,238,246,0.9)","user_followers_path":"\/tatXtxt\/followers","screen_name_from_server":"tatXtxt","profile_image_url_from_server":"http:\/\/a1.twimg.com\/sticky\/default_profile_images\/default_profile_2_normal.png","rgba_newtweets_border_color":"rgba(0,132,180,0.25)","rgba_tweet_background_color":"rgba(0,132,180,0.1)","subscriptions_path":"\/tatXtxt\/lists\/subscriptions","user_favorites_path":"\/tatXtxt\/favorites","profile_path":"\/tatXtxt","id":327319701,"rgba_newtweets_background_color":"rgba(0,132,180,0.2)","lists_path":"\/tatXtxt\/lists","rgba_text_color":"rgba(51,51,51,0.6)","user_following_path":"\/tatXtxt\/following","latest_timestamp":"","account_profile_image_path":"\/account\/profile_image\/tatXtxt","bigger_profile_image_url":"http:\/\/a1.twimg.com\/sticky\/default_profile_images\/default_profile_2.png"},"requestFullCity":"br,05,feira_de_santana","postAuthenticityToken":"3de1b517590cad537393d7c2999d024524c8b492","isAdmin":false}
START;
print_r(json_decode($json));
Thank you in advance
I escaped all single quotes with \' and encapsulated it all with single quotes and it seems to work:
<?php
$json = '{"currentUserScreenName":"tatXtxt","recentPlaces":[],"cdnBase":{"versioned":{"ssl":["https:\/\/si0.twimg.com\/a\/1309465578"],"http":["http:\/\/a0.twimg.com\/a\/1309465578","http:\/\/a1.twimg.com\/a\/1309465578","http:\/\/a2.twimg.com\/a\/1309465578","http:\/\/a3.twimg.com\/a\/1309465578"]},"unversioned":{"ssl":["https:\/\/si0.twimg.com"],"http":["http:\/\/a0.twimg.com","http:\/\/a1.twimg.com","http:\/\/a2.twimg.com","http:\/\/a3.twimg.com"]}},"pageLocaleJS":"http:\/\/a3.twimg.com\/a\/1309465578\/javascripts\/phoenix\/i18n\/pt.js","becameUser":false,"payload":{"profiling":false,"conditionalTemplates":{}},"isNarrow":true,"deciderFeatures":{"tweet_stream_list":1,"geo_location":1,"people_stream_friends":1,"tweet_stream_favorites":1,"promo_component":1,"phoenix_local_gowalla":1,"new_trends_location_selector":1,"geo_ui":1,"flock":1,"phoenix_geo_v4":1,"geo_ui_dropdown_available":1,"tweet_stream_mentions_polling":1,"contact_import_stream":1,"html5Routing":1,"list_stream_memberships":1,"phoenix_frontpage_rotate_avatars":1,"tweet_stream_retweets_by_you":1,"inline_media_component":1,"whotofollow_random_sample":1,"phoenix_sandboxed_ajax":1,"tweet_stream_following_polling":1,"whotofollow_recommendations":1,"phoenix_first_time":1,"list_stream_own_lists":1,"phoenix_facets_logged_out":1,"phoenix_amazon_details":1,"in_reply_to_component":1,"sync_scribe":1,"geo_show_similar_places":1,"phoenix_turkey_permalink":1,"tweet_streams_polling":1,"media_flagging":1,"phoenix_search_relevance_logged_out":1,"user_shuffler":1,"mobile_download_gallery_logged_out":1,"phoenix_aol_video":1,"logged_out_people_search":1,"social_context":1,"email_device_settings":1,"people_streams":1,"tweet_stream_user_polling":1,"tweet_stream_retweets_by_you_polling":1,"people_stream_people_search":1,"phoenix_local_plancast":1,"scribe_client_event":1,"tweet_streams":1,"profile_combined_api":1,"tweet_stream_user":1,"phoenix_facets_videos":1,"phoenix_instagram_and_friends":1,"tweet_geo_component":1,"tweet_stream_mentions":1,"phoenix_tweetbox_talon":1,"phoenix_scribe":1,"phoenix_local_meetup":1,"tweet_stream_search":1,"phoenix_facets":1,"dashboard_activity_following":1,"retweeters_component":1,"people_stream_list_followers":1,"more_lists_component":1,"mt_tweet_backend_bing":1,"phoenix_talon_on_copy":1,"place_users_stream":1,"message_stream":1,"tweet_stream_home":1,"phoenix_autocomplete_place_trigger_words":1,"dashboard_activity_favorites":1,"dashboard_activity_listed":1,"list_streams":1,"tweet_stream_your_tweets_retweeted_polling":1,"phoenix_local_foursquare":1,"phoenix_puffin":1,"tweet_stream_list_polling":1,"tweet_stream_retweets_by_others":1,"phoenix_search_dropdown":1,"people_stream_follower_requests":1,"tweet_stream_home_polling":1,"trends_component":1,"phoenix_search_relevance":1,"tweet_stream_your_tweets_retweeted":1,"phoenix_pretty_links":1,"local_trends":1,"place_people_component":1,"people_stream_list_members":1,"place_tweets_component":1,"dashboard_activity_followers":1,"following_page_tweets_tab":1,"list_stream_subscriptions":1,"tweet_stream_retweets_by_others_polling":1,"mobile_download_gallery":1,"geo_more_places":1,"japanese_ad_component":1,"infinite_scroll":1,"tweet_stream_search_polling":1,"whotofollow_similarities":1,"people_stream_followers":1,"recent_tweets_component":1,"tweet_stream_favorites_polling":1,"welcome_warm_signup":1,"geo_allow_set_location_manually":1,"promptbird_phoenix":1,"phoenix_facets_images":1,"promoted_accounts_in_whotofollow_viewall":1,"suggestion_categories_streams":1,"geo_place_creation":1,"conversations":1,"tweet_stream_following":1,"phoenix_autocomplete":1,"onebox_user_search":1,"advanced_search":1,"i18n_new_translation_center":1,"fake_loggedout_decider":1,"newest_list_members_component":1},"adminRights":false,"isPreflight":false,"languages":[{"css_classes":"western pt","name":"Portugu\u00eas","code":"pt","name_en":"Portuguese"},{"css_classes":"western it","name":"Italiano","code":"it","name_en":"Italian"},{"css_classes":"western es","name":"Espa\u00f1ol","code":"es","name_en":"Spanish"},{"css_classes":"western tr","name":"T\u00fcrk\u00e7e","code":"tr","name_en":"Turkish"},{"css_classes":null,"name":"English","code":"en","name_en":"English"},{"css_classes":"asian ko","name":"\ud55c\uad6d\uc5b4","code":"ko","name_en":"Korean"},{"css_classes":"western fr","name":"fran\u00e7ais","code":"fr","name_en":"French"},{"css_classes":"western ru","name":"\u0420\u0443\u0441\u0441\u043a\u0438\u0439","code":"ru","name_en":"Russian"},{"css_classes":"western de","name":"Deutsch","code":"de","name_en":"German"},{"css_classes":"asian ja","name":"\u65e5\u672c\u8a9e","code":"ja","name_en":"Japanese"}],"abBuckets":{"remember_me_on_signup_83":{"bucket":"experiment","version":9,"experiment_key":"remember_me_on_signup_83","bucket_names":["control","experiment"]},"Contact_Import_Images-40":{"bucket":"control","version":3,"experiment_key":"Contact_Import_Images-40","bucket_names":["control","images"]},"Contact_Import_Services-39":{"bucket":"control","version":4,"experiment_key":"Contact_Import_Services-39","bucket_names":["control","vertical","vertical_matched"]},"welcome_flow_addressbook_81":{"bucket":"control","version":8,"experiment_key":"welcome_flow_addressbook_81","bucket_names":["control","addressbook"]},"Relevance_V1-49":{"bucket":"control","version":10,"experiment_key":"Relevance_V1-49","bucket_names":["control","recent"]}},"pageLocaleClass":"western pt","pageLocale":"pt","globalConfig":{"photo_sizes":{"large":{"h":2048,"resize":"fit","w":1024},"medium":{"h":1200,"resize":"fit","w":600},"thumb":{"h":150,"resize":"crop","w":150},"small":{"h":480,"resize":"fit","w":340}},"non_username_paths":["about","account","accounts","activity","all","announcements","anywhere","api_rules","api_terms","apirules","apps","auth","badges","blog","business","buttons","contacts","devices","direct_messages","download","downloads","edit_announcements","faq","favorites","find_sources","find_users","followers","following","friend_request","friendrequest","friends","goodies","help","home","im_account","inbox","invitations","invite","jobs","list","login","logout","me","mentions","messages","newtwitter","notifications","nudge","oauth","phoenix_search","positions","privacy","public_timeline","related_tweets","replies","retweeted_of_mine","retweets","retweets_by_others","rules","saved_searches","search","sent","settings","share","signup","signin","similar_to","statistics","terms","tos","translate","trends","tweetbutton","twttr","update_discoverability","users","welcome","who_to_follow","widgets","zendesk_auth","media_signup","phoenix_qunit_tests"],"max_media_per_upload":1,"short_url_length_https":20,"characters_reserved_per_media":20,"photo_size_limit":3145728,"short_url_length":19},"requestCacheSeedData":[{"options":[{}],"json":{"profile_sidebar_border_color":"C0DEED","profile_background_tile":false,"profile_sidebar_fill_color":"DDEEF6","name":"Testando","created_at":"Fri Jul 01 11:10:49 +0000 2011","location":null,"profile_image_url":"http:\/\/a1.twimg.com\/sticky\/default_profile_images\/default_profile_2_normal.png","is_translator":false,"profile_link_color":"0084B4","id_str":"327319701","follow_request_sent":false,"contributors_enabled":false,"favourites_count":0,"states":{"pending_email":"testandoXXXX#hotmail.com","bouncing_email":["testandoXXXX#hotmail.com"],"detached_email":false,"suspended":false,"needs_employee_email_update":false},"url":null,"default_profile":true,"id":327319701,"utc_offset":null,"profile_image_url_https":"https:\/\/si0.twimg.com\/sticky\/default_profile_images\/default_profile_2_normal.png","profile_use_background_image":true,"listed_count":0,"lang":"pt","followers_count":0,"profile_text_color":"333333","protected":false,"profile_background_color":"C0DEED","profile_background_image_url_https":"https:\/\/si0.twimg.com\/images\/themes\/theme1\/bg.png","verified":false,"time_zone":null,"geo_enabled":false,"description":null,"notifications":false,"statuses_count":0,"default_profile_image":true,"friends_count":0,"profile_background_image_url":"http:\/\/a0.twimg.com\/images\/themes\/theme1\/bg.png","show_all_inline_media":false,"following":false,"screen_name":"tatXtxt"},"api_request_name":"account\/verify_credentials"},{"options":[{"include_available_features":1,"include_entities":1,"pc":true,"contributor_details":true}],"json":[],"api_request_name":"statuses\/home_timeline"},{"options":[{}],"json":{"sleep_time":{"end_time":null,"enabled":false,"start_time":null},"language":"pt","discoverable_by_email":true,"always_use_https":false,"geo_enabled":false},"api_request_name":"account\/settings"},{"options":[{"pc":true}],"json":{"trends":{"current_trends":[{"name":"#listentoyourheart","url":"http:\/\/search.twitter.com\/search?q=%23listentoyourheart"},{"name":"#youneedtositdown","url":"http:\/\/search.twitter.com\/search?q=%23youneedtositdown"},{"name":"Teddy Bautista","url":"http:\/\/search.twitter.com\/search?q=%22Teddy%20Bautista%22"},{"name":"#eqakl","url":"http:\/\/search.twitter.com\/search?q=%23eqakl"},{"name":"Mayor Duterte","url":"http:\/\/search.twitter.com\/search?q=%22Mayor%20Duterte%22"},{"name":"Brendon Urie","url":"http:\/\/search.twitter.com\/search?q=%22Brendon%20Urie%22"},{"name":"Mirror Mirror","url":"http:\/\/search.twitter.com\/search?q=%22Mirror%20Mirror%22"},{"name":"BTD","url":"http:\/\/search.twitter.com\/search?q=BTD"},{"name":"\'Perfect Night\'","url":"http:\/\/search.twitter.com\/search?q=%22\'Perfect%20Night\'%22"},{"name":"Black & White","url":"http:\/\/search.twitter.com\/search?q=%22Black%20&%20White%22"}]}},"api_request_name":"trends\/current"},{"options":[{}],"json":{"promo":{"name":"IOC Olympic Day (PT)","created_at":"Wed Jun 22 21:28:29 +0000 2011","promo_contents":"\u003Ca href=\"http:\/\/contest.olympic.org\/\" class=\"definition\" onClick=\"javascript: pageTracker._trackPageview(\'\/\ndefinition\/IOC_pt\');\"\u003E\u003Cstrong\u003EDia Ol\u00edmpico no Twitter\u003C\/strong\u003E\u003C\/a\u003E Comemore o espir\u00edto dos Jogos Ol\u00edmpicos no Twitter e voc\u00ea poder\u00e1 ganhar uma viagem a Londres 2012.","promo_type":"","updated_at":"Thu Jun 23 17:00:45 +0000 2011","id":150,"is_sponsored":false,"is_active":true,"locale":"pt"}},"api_request_name":"promos\/random"}],"remoteIP":"189.104.75.181","appcacheRequiredMajorVersion":1,"userProperties":{"emailDiscoverabilitySet":true,"mobilePhoneDiscoverabilitySet":false,"deviceAddress":null,"discoverableByEmail":true,"discoverableByMobilePhone":false,"emailAddress":"null","deviceSetup":false},"currentUser":{"memberships_path":"\/tatXtxt\/lists\/memberships","rgba_tweet_border_color":"rgba(0,132,180,0.15)","linkified_status":"","rgba_sidebar_color":"rgba(221,238,246,0.9)","user_followers_path":"\/tatXtxt\/followers","screen_name_from_server":"tatXtxt","profile_image_url_from_server":"http:\/\/a1.twimg.com\/sticky\/default_profile_images\/default_profile_2_normal.png","rgba_newtweets_border_color":"rgba(0,132,180,0.25)","rgba_tweet_background_color":"rgba(0,132,180,0.1)","subscriptions_path":"\/tatXtxt\/lists\/subscriptions","user_favorites_path":"\/tatXtxt\/favorites","profile_path":"\/tatXtxt","id":327319701,"rgba_newtweets_background_color":"rgba(0,132,180,0.2)","lists_path":"\/tatXtxt\/lists","rgba_text_color":"rgba(51,51,51,0.6)","user_following_path":"\/tatXtxt\/following","latest_timestamp":"","account_profile_image_path":"\/account\/profile_image\/tatXtxt","bigger_profile_image_url":"http:\/\/a1.twimg.com\/sticky\/default_profile_images\/default_profile_2.png"},"requestFullCity":"br,05,feira_de_santana","postAuthenticityToken":"3de1b517590cad537393d7c2999d024524c8b492","isAdmin":false}';
print_r(json_decode($json));
PHP parses the string (heredoc) literal in your script. And \ may have a special meaning depending on the character that follows. If you want a \ in your string you should/must write \\ in your literal
$json = <<<START
{"currentUserScreenName":"tatXtxt","recentPlaces":[],"cdnBase":{"versioned":{"ssl":["https:\\/\\/si0.twimg.com\\/a\\/1309465578"],"http":["http:\\/\\/a0.twimg.com\\/a\\/1309465578","http:\\/\\/a1.twimg.com\\/a\\/1309465578","http:\\/\\/a2.twimg.com\\/a\\/1309465578","http:\\/\\/a3.twimg.com\\/a\\/1309465578"]},"unversioned":{"ssl":["https:\\/\\/si0.twimg.com"],"http":["http:\\/\\/a0.twimg.com","http:\\/\\/a1.twimg.com","http:\\/\\/a2.twimg.com","http:\\/\\/a3.twimg.com"]}},"pageLocaleJS":"http:\\/\\/a3.twimg.com\\/a\\/1309465578\\/javascripts\\/phoenix\\/i18n\\/pt.js","becameUser":false,"payload":{"profiling":false,"conditionalTemplates":{}},"isNarrow":true,"deciderFeatures":{"tweet_stream_list":1,"geo_location":1,"people_stream_friends":1,"tweet_stream_favorites":1,"promo_component":1,"phoenix_local_gowalla":1,"new_trends_location_selector":1,"geo_ui":1,"flock":1,"phoenix_geo_v4":1,"geo_ui_dropdown_available":1,"tweet_stream_mentions_polling":1,"contact_import_stream":1,"html5Routing":1,"list_stream_memberships":1,"phoenix_frontpage_rotate_avatars":1,"tweet_stream_retweets_by_you":1,"inline_media_component":1,"whotofollow_random_sample":1,"phoenix_sandboxed_ajax":1,"tweet_stream_following_polling":1,"whotofollow_recommendations":1,"phoenix_first_time":1,"list_stream_own_lists":1,"phoenix_facets_logged_out":1,"phoenix_amazon_details":1,"in_reply_to_component":1,"sync_scribe":1,"geo_show_similar_places":1,"phoenix_turkey_permalink":1,"tweet_streams_polling":1,"media_flagging":1,"phoenix_search_relevance_logged_out":1,"user_shuffler":1,"mobile_download_gallery_logged_out":1,"phoenix_aol_video":1,"logged_out_people_search":1,"social_context":1,"email_device_settings":1,"people_streams":1,"tweet_stream_user_polling":1,"tweet_stream_retweets_by_you_polling":1,"people_stream_people_search":1,"phoenix_local_plancast":1,"scribe_client_event":1,"tweet_streams":1,"profile_combined_api":1,"tweet_stream_user":1,"phoenix_facets_videos":1,"phoenix_instagram_and_friends":1,"tweet_geo_component":1,"tweet_stream_mentions":1,"phoenix_tweetbox_talon":1,"phoenix_scribe":1,"phoenix_local_meetup":1,"tweet_stream_search":1,"phoenix_facets":1,"dashboard_activity_following":1,"retweeters_component":1,"people_stream_list_followers":1,"more_lists_component":1,"mt_tweet_backend_bing":1,"phoenix_talon_on_copy":1,"place_users_stream":1,"message_stream":1,"tweet_stream_home":1,"phoenix_autocomplete_place_trigger_words":1,"dashboard_activity_favorites":1,"dashboard_activity_listed":1,"list_streams":1,"tweet_stream_your_tweets_retweeted_polling":1,"phoenix_local_foursquare":1,"phoenix_puffin":1,"tweet_stream_list_polling":1,"tweet_stream_retweets_by_others":1,"phoenix_search_dropdown":1,"people_stream_follower_requests":1,"tweet_stream_home_polling":1,"trends_component":1,"phoenix_search_relevance":1,"tweet_stream_your_tweets_retweeted":1,"phoenix_pretty_links":1,"local_trends":1,"place_people_component":1,"people_stream_list_members":1,"place_tweets_component":1,"dashboard_activity_followers":1,"following_page_tweets_tab":1,"list_stream_subscriptions":1,"tweet_stream_retweets_by_others_polling":1,"mobile_download_gallery":1,"geo_more_places":1,"japanese_ad_component":1,"infinite_scroll":1,"tweet_stream_search_polling":1,"whotofollow_similarities":1,"people_stream_followers":1,"recent_tweets_component":1,"tweet_stream_favorites_polling":1,"welcome_warm_signup":1,"geo_allow_set_location_manually":1,"promptbird_phoenix":1,"phoenix_facets_images":1,"promoted_accounts_in_whotofollow_viewall":1,"suggestion_categories_streams":1,"geo_place_creation":1,"conversations":1,"tweet_stream_following":1,"phoenix_autocomplete":1,"onebox_user_search":1,"advanced_search":1,"i18n_new_translation_center":1,"fake_loggedout_decider":1,"newest_list_members_component":1},"adminRights":false,"isPreflight":false,"languages":[{"css_classes":"western pt","name":"Portugu\\u00eas","code":"pt","name_en":"Portuguese"},{"css_classes":"western it","name":"Italiano","code":"it","name_en":"Italian"},{"css_classes":"western es","name":"Espa\\u00f1ol","code":"es","name_en":"Spanish"},{"css_classes":"western tr","name":"T\\u00fcrk\\u00e7e","code":"tr","name_en":"Turkish"},{"css_classes":null,"name":"English","code":"en","name_en":"English"},{"css_classes":"asian ko","name":"\\ud55c\\uad6d\\uc5b4","code":"ko","name_en":"Korean"},{"css_classes":"western fr","name":"fran\\u00e7ais","code":"fr","name_en":"French"},{"css_classes":"western ru","name":"\\u0420\\u0443\\u0441\\u0441\\u043a\\u0438\\u0439","code":"ru","name_en":"Russian"},{"css_classes":"western de","name":"Deutsch","code":"de","name_en":"German"},{"css_classes":"asian ja","name":"\\u65e5\\u672c\\u8a9e","code":"ja","name_en":"Japanese"}],"abBuckets":{"remember_me_on_signup_83":{"bucket":"experiment","version":9,"experiment_key":"remember_me_on_signup_83","bucket_names":["control","experiment"]},"Contact_Import_Images-40":{"bucket":"control","version":3,"experiment_key":"Contact_Import_Images-40","bucket_names":["control","images"]},"Contact_Import_Services-39":{"bucket":"control","version":4,"experiment_key":"Contact_Import_Services-39","bucket_names":["control","vertical","vertical_matched"]},"welcome_flow_addressbook_81":{"bucket":"control","version":8,"experiment_key":"welcome_flow_addressbook_81","bucket_names":["control","addressbook"]},"Relevance_V1-49":{"bucket":"control","version":10,"experiment_key":"Relevance_V1-49","bucket_names":["control","recent"]}},"pageLocaleClass":"western pt","pageLocale":"pt","globalConfig":{"photo_sizes":{"large":{"h":2048,"resize":"fit","w":1024},"medium":{"h":1200,"resize":"fit","w":600},"thumb":{"h":150,"resize":"crop","w":150},"small":{"h":480,"resize":"fit","w":340}},"non_username_paths":["about","account","accounts","activity","all","announcements","anywhere","api_rules","api_terms","apirules","apps","auth","badges","blog","business","buttons","contacts","devices","direct_messages","download","downloads","edit_announcements","faq","favorites","find_sources","find_users","followers","following","friend_request","friendrequest","friends","goodies","help","home","im_account","inbox","invitations","invite","jobs","list","login","logout","me","mentions","messages","newtwitter","notifications","nudge","oauth","phoenix_search","positions","privacy","public_timeline","related_tweets","replies","retweeted_of_mine","retweets","retweets_by_others","rules","saved_searches","search","sent","settings","share","signup","signin","similar_to","statistics","terms","tos","translate","trends","tweetbutton","twttr","update_discoverability","users","welcome","who_to_follow","widgets","zendesk_auth","media_signup","phoenix_qunit_tests"],"max_media_per_upload":1,"short_url_length_https":20,"characters_reserved_per_media":20,"photo_size_limit":3145728,"short_url_length":19},"requestCacheSeedData":[{"options":[{}],"json":{"profile_sidebar_border_color":"C0DEED","profile_background_tile":false,"profile_sidebar_fill_color":"DDEEF6","name":"Testando","created_at":"Fri Jul 01 11:10:49 +0000 2011","location":null,"profile_image_url":"http:\\/\\/a1.twimg.com\\/sticky\\/default_profile_images\\/default_profile_2_normal.png","is_translator":false,"profile_link_color":"0084B4","id_str":"327319701","follow_request_sent":false,"contributors_enabled":false,"favourites_count":0,"states":{"pending_email":"testandoXXXX#hotmail.com","bouncing_email":["testandoXXXX#hotmail.com"],"detached_email":false,"suspended":false,"needs_employee_email_update":false},"url":null,"default_profile":true,"id":327319701,"utc_offset":null,"profile_image_url_https":"https:\\/\\/si0.twimg.com\\/sticky\\/default_profile_images\\/default_profile_2_normal.png","profile_use_background_image":true,"listed_count":0,"lang":"pt","followers_count":0,"profile_text_color":"333333","protected":false,"profile_background_color":"C0DEED","profile_background_image_url_https":"https:\\/\\/si0.twimg.com\\/images\\/themes\\/theme1\\/bg.png","verified":false,"time_zone":null,"geo_enabled":false,"description":null,"notifications":false,"statuses_count":0,"default_profile_image":true,"friends_count":0,"profile_background_image_url":"http:\\/\\/a0.twimg.com\\/images\\/themes\\/theme1\\/bg.png","show_all_inline_media":false,"following":false,"screen_name":"tatXtxt"},"api_request_name":"account\\/verify_credentials"},{"options":[{"include_available_features":1,"include_entities":1,"pc":true,"contributor_details":true}],"json":[],"api_request_name":"statuses\\/home_timeline"},{"options":[{}],"json":{"sleep_time":{"end_time":null,"enabled":false,"start_time":null},"language":"pt","discoverable_by_email":true,"always_use_https":false,"geo_enabled":false},"api_request_name":"account\\/settings"},{"options":[{"pc":true}],"json":{"trends":{"current_trends":[{"name":"#listentoyourheart","url":"http:\\/\\/search.twitter.com\\/search?q=%23listentoyourheart"},{"name":"#youneedtositdown","url":"http:\\/\\/search.twitter.com\\/search?q=%23youneedtositdown"},{"name":"Teddy Bautista","url":"http:\\/\\/search.twitter.com\\/search?q=%22Teddy%20Bautista%22"},{"name":"#eqakl","url":"http:\\/\\/search.twitter.com\\/search?q=%23eqakl"},{"name":"Mayor Duterte","url":"http:\\/\\/search.twitter.com\\/search?q=%22Mayor%20Duterte%22"},{"name":"Brendon Urie","url":"http:\\/\\/search.twitter.com\\/search?q=%22Brendon%20Urie%22"},{"name":"Mirror Mirror","url":"http:\\/\\/search.twitter.com\\/search?q=%22Mirror%20Mirror%22"},{"name":"BTD","url":"http:\\/\\/search.twitter.com\\/search?q=BTD"},{"name":"'Perfect Night'","url":"http:\\/\\/search.twitter.com\\/search?q=%22'Perfect%20Night'%22"},{"name":"Black & White","url":"http:\\/\\/search.twitter.com\\/search?q=%22Black%20&%20White%22"}]}},"api_request_name":"trends\\/current"},{"options":[{}],"json":{"promo":{"name":"IOC Olympic Day (PT)","created_at":"Wed Jun 22 21:28:29 +0000 2011","promo_contents":"\\u003Ca href=\\"http:\\/\\/contest.olympic.org\\/\\" class=\\"definition\\" onClick=\\"javascript: pageTracker._trackPageview('\\/\\ndefinition\\/IOC_pt');\\"\\u003E\\u003Cstrong\\u003EDia Ol\\u00edmpico no Twitter\\u003C\\/strong\\u003E\\u003C\\/a\\u003E Comemore o espir\\u00edto dos Jogos Ol\\u00edmpicos no Twitter e voc\\u00ea poder\\u00e1 ganhar uma viagem a Londres 2012.","promo_type":"","updated_at":"Thu Jun 23 17:00:45 +0000 2011","id":150,"is_sponsored":false,"is_active":true,"locale":"pt"}},"api_request_name":"promos\\/random"}],"remoteIP":"189.104.75.181","appcacheRequiredMajorVersion":1,"userProperties":{"emailDiscoverabilitySet":true,"mobilePhoneDiscoverabilitySet":false,"deviceAddress":null,"discoverableByEmail":true,"discoverableByMobilePhone":false,"emailAddress":"null","deviceSetup":false},"currentUser":{"memberships_path":"\\/tatXtxt\\/lists\\/memberships","rgba_tweet_border_color":"rgba(0,132,180,0.15)","linkified_status":"","rgba_sidebar_color":"rgba(221,238,246,0.9)","user_followers_path":"\\/tatXtxt\\/followers","screen_name_from_server":"tatXtxt","profile_image_url_from_server":"http:\\/\\/a1.twimg.com\\/sticky\\/default_profile_images\\/default_profile_2_normal.png","rgba_newtweets_border_color":"rgba(0,132,180,0.25)","rgba_tweet_background_color":"rgba(0,132,180,0.1)","subscriptions_path":"\\/tatXtxt\\/lists\\/subscriptions","user_favorites_path":"\\/tatXtxt\\/favorites","profile_path":"\\/tatXtxt","id":327319701,"rgba_newtweets_background_color":"rgba(0,132,180,0.2)","lists_path":"\\/tatXtxt\\/lists","rgba_text_color":"rgba(51,51,51,0.6)","user_following_path":"\\/tatXtxt\\/following","latest_timestamp":"","account_profile_image_path":"\\/account\\/profile_image\\/tatXtxt","bigger_profile_image_url":"http:\\/\\/a1.twimg.com\\/sticky\\/default_profile_images\\/default_profile_2.png"},"requestFullCity":"br,05,feira_de_santana","postAuthenticityToken":"3de1b517590cad537393d7c2999d024524c8b492","isAdmin":false}
START;

Categories