Danh mục

Building OpenSocial Apps- P3

Số trang: 50      Loại file: pdf      Dung lượng: 0.00 B      Lượt xem: 21      Lượt tải: 0    
Thư viện của tui

Xem trước 5 trang đầu tiên của tài liệu này:

Thông tin tài liệu:

Building OpenSocial Apps- P3: Nhà phát triển của Thư viện Series từ Addison-Wesley cung cấphành nghề lập trình với độc đáo, tài liệu tham khảo chất lượng caohướng dẫn về các ngôn ngữ lập trình công nghệ mới nhất và họsử dụng trong công việc hàng ngày của họ. Tất cả các sách trong thư viện của Nhà phát triển được viết bởichuyên gia công nghệ các học viên những người có kỹ năng đặc biệt tại các tổ chứcvà trình bày thông tin một cách đó là hữu ích cho các lập trình viên khác....
Nội dung trích xuất từ tài liệu:
Building OpenSocial Apps- P3 74 Chapter 5 Communication and Viral Features // Update the UI for the failures for(var i = 0; i < failure.length; i++){ clicked = current_list.list_dom[myspace.com: + failure[i]]; if(clicked) clicked.style.backgroundColor = red; } } } } So, there is a lot going on here.The callback for requestShareApp is especially important.The first thing that really happens is that the various types of errors are trapped, and an error message is displayed if one is found. If there was no error, we cycle through the list of currently selected users, revert the background of the corresponding div tags to white, and reset the list.There are now two possibilities: the user either canceled the pop-up or hit Send. If the pop-up was canceled, there’s no more work to do. If the pop-up wasn’t canceled, the user must have hit the Send button, so we need to figure out who the actual recipients were.We do this by accessing the responseValues object in the ResponseItem that’s passed back to us. responseValues contains two arrays: One, success, contains the list of users who were successfully sent an invite.The other, failure, contains the list of users who had an error occur when the invite was sent. Both arrays contain the integer IDs of the specified users. There are a couple of things to note when accessing the success and failure arrays. First, users who already have the app installed won’t get the invite, but neither will they show up in either array. Second, the IDs in the array are integers, so they don’t exactly match the IDs that are sent by the API (in the format myspace.com:6221). Back to the function at hand.We extract the success and failure arrays and loop through them.We turn the background color of all the successful recipients to green, and that of all the failures to red.You’ll notice that we have to append myspace.com: to the beginning of each ID so it matches up with the IDs we fetched from the API. It may be useful to add a More button to your app, something like “Select Random 20” that will randomly select 20 of the user’s friends.This will help encourage users to share the app with a larger group of friends; turning 20 clicks into one click makes it much easier for your users. Using opensocial.requestSendMessage to Send Messages and Communications Let’s examine how opensocial.requestSendMessage works.The requestSendMessage function provides a number of ways for apps to communicate with users. MySpace supports the following message types: n Send Message: a private one-to-one message that will arrive in the user’s Mail Center in-box n Comment: a public one-to-one message that will appear on the user’s Profile page in the Comments sectionPlease purchase PDF Split-Merge on www.verypdf.com to remove this watermark. Using opensocial.requestSendMessage to Send Messages and Communications 75 n Bulletin: a one-to-many message that will appear in the Bulletins module of each of the user’s friends’ Home pages n Blog: a one-to-many message that will appear on a MySpace user’s Blog n Profile: not a message per se; allows an app to edit/update the user’s Profile.The following Profile sections can be edited and are chosen by the user in a drop- down menu: About Me I’d Like to Meet Interests Edit Artist Profile Movies Television Books Heroes Defining requestSendMessage opensocial.requestSendMessage has the following signature: opensocial.requestSendMessage = function(recipients, message, opt_callback, opt_params) You probably noticed that the signature for opensocial.requestSendMessage is very similar to that of opensocial.requestShareApp.The big difference is that you’re allowed to define only one recipient ID at a time; the container will reject an array of IDs. Similar to requestShareApp, however, are opt_callback, which is the function that’s invoked when the pop-up modal has closed, and opt_params, whic ...

Tài liệu được xem nhiều: