小编Hom*_*ale的帖子

使用RESTful服务保护跨域的API调用

我有一个预订网站,我向用户提供了几行代码,我在其中添加了API密钥div以及代码.用户需要在他们的网站中添加这些代码.然后我使用ajax调用从我的站点加载他们站点上的视图.我担心的是:如何使用公共和私有API密钥使用codeIgniter使用restful Web服务来保证这些调用的安全性?

我提供给用户的代码看起来像

    <link rel="stylesheet" type="text/css" href="http://localhost/bookingpoints_com/apiTesting/styles/first.css" />
    <script src="http://localhost/bookingpoints_com/contents/scripts/jquery.js" ></script>
    <script src="http://localhost/bookingpoints_com/contents/scripts/apiused.js" ></script>
    <script src="http://localhost/bookingpoints_com/apiTesting/scripts/common.js" ></script>         
    <div id="api-data-reserve" name="Njc4ZDI5ZDZiN2RlYzIxMzM1N2U3ZWRkOGEwYjhlNThhZmZiNDNjNXRlc3QgY29kZTE=" data="Njc4ZDI5ZDZiN2RlYzIxMzM1N2U3ZWRkOGEwYjhlNThhZmZiNDNjNW1HVnZ3YVhMRVc=" sitekey="Njc4ZDI5ZDZiN2RlYzIxMzM1N2U3ZWRkOGEwYjhlNThhZmZiNDNjNQ=="></div>
Run Code Online (Sandbox Code Playgroud)

通过这些代码行,我对我的站点进行了ajax调用,并在用户站点上呈现视图.如何使用纯API架构使用restful服务进行身份验证,使其像google的客户端和密钥结构一样工作?

php api ajax rest codeigniter

8
推荐指数
1
解决办法
922
查看次数

循环通过json键检查其值是否为空

我有这个json对象.Json键remarks并且address是空的.如果它为空,则undefine在提取json时打印json.但我想用-标志替换空的json .我知道我可以用:

 if(msg.hasOwnProperty('remarks')== ""){
        alert("A");
   }
Run Code Online (Sandbox Code Playgroud)

但是如何遍历所有键并检查它是否为空并替换-而不是单独检查它.

[
{
    "id": "224",
    "booking_id": "1",
    "room_type": null,
    "no_of_rooms_booked": null,
    "check_in_date": "2014-12-23",
    "check_out_date": "2014-12-24",
    "room_id": "93",
    "hotel_id": "9",
    "status": "1",
    "user_id": "15",
    "payment_type": "",
    "payment_status": "",
    "hotelname": "sample hotel",
    "hoteladdress": "sample address",
    "hotelcontact": "056533977",
    "Id": "224",
    "full_name": "Hom Nath Bagale",
    "address": "",
    "occupation": "Student",
    "nationality": "Nepali",
    "contact_no": "9845214140",
    "email": "bhomnath@salyani.com.np",
    "remarks": "",
    "total_amount": "5000",
    "child": "0",
    "adult": "1",
    "verification_code": null,
    "roomname": "sample room2", …
Run Code Online (Sandbox Code Playgroud)

performance jquery json

1
推荐指数
1
解决办法
9860
查看次数

什么是500错误?

我使用Codeigniter作为我的Php框架.我创建了简单的房间预订系统.在本地我没有得到任何错误,但在服务器我得到500错误?导致此类错误的原因是什么?如何解决?

html php codeigniter

-1
推荐指数
1
解决办法
3278
查看次数

标签 统计

codeigniter ×2

php ×2

ajax ×1

api ×1

html ×1

jquery ×1

json ×1

performance ×1

rest ×1