使用AJAX将JSON数据设置为PHP中的变量 [英] Setting JSON data into variables in PHP using AJAX

查看:111
本文介绍了使用AJAX将JSON数据设置为PHP中的变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





使用twitter API twitteroauth,我检索了json格式的凭据,如下所示:



{oauth_token:XXXXXXXXXXXXXXXXXXXXXXX,oauth_token_secret:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX,user_id:123456789,screen_name:myTwitterUsername}



我如何使用AJAX从上面的JSON结果中获取user_id和screen_name并将它们存储到PHP中的单独变量中,以便可以在UI上使用它们?

Hi,

Using the twitter API twitteroauth, I retrieved credentials in json format as shown below:

{"oauth_token":"XXXXXXXXXXXXXXXXXXXXXXX","oauth_token_secret":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX","user_id":"123456789","screen_name":"myTwitterUsername"}

How would I use AJAX to get the user_id and screen_name from the JSON results above and store them into seperate variables in PHP so that they can be used on the UI?

推荐答案

问题不够明确,但你可能只需要PHP json_decode

http://php.net/manual/en/function.json-decode.php [ ^ ]。



-SA
The question is not clear enough, but it's possible that you just need PHP json_decode:
http://php.net/manual/en/function.json-decode.php[^].

—SA


这篇关于使用AJAX将JSON数据设置为PHP中的变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆