Board index   FAQ   Search  
Register  Login
Board index PHP PEAR and PECL

Services_JSON for facebook app

Do you have questions regarding Pecl or Pear? ask here!

Moderators: macek, egami, gesf

Services_JSON for facebook app

Postby glardon » Sat Aug 06, 2011 9:24 am

Hello

I have started my first facebook app / tab. Since the version of PHP on my shared hosting is still 5.1 i cannot use the the built-in json_decode function that is available from v5.2.

Therefor I downloaded the Services_JSON files from PEAR that can be included stand-alone. Howver I cannot get the json_decode to work which is needed to decode the payload data that is send by facebook to my app.

If I use my code on a server with PHP v5.3 my code works.

Anyone any idea?

This is an example payload I receive from facebook and need to decode:
Code: Select all
{"algorithm":"HMAC-SHA256","expires":1312632000,"issued_at":1312627940,"oauth_token":"227297140647453|2.AQD5Zng4bNL4xg6M.3600.1312632000.0-685004964|G22oD8VMYhaGvBQdcZy4pzB1qqo","page":{"id":"222788941091215","liked":true,"admin":true},"user":{"country":"be","locale":"nl_NL","age":{"min":21}},"user_id":"685004964"}


This is the code snippet that I isolated that causes the problem:
Code: Select all
$payload = base64_decode(strtr($payload, '-_', '+/'));
$data = json_decode($payload, true);


My script always seems to stop running at the second line. As i checked, the json_decode function exists.

Many tnx
Gino
glardon
New php-forum User
New php-forum User
 
Posts: 1
Joined: Sat Aug 06, 2011 9:04 am

Return to PEAR and PECL

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron