【从apprequest facebook api请求数据】宁可枝头抱香死,何曾吹落北风中。这篇文章主要讲述从apprequest facebook api请求数据相关的知识,希望能为你提供帮助。
Rescatamos los datos que pasamos por apprequest .
- //C?3digo javascript
- function sendRequest( user) {
- FB.ui( {
- method: 'apprequests',
- title: 'Concurso Hipoglos',
- message: 'Invita a tus amigos a subir a tu bus de hipoglos y ganar fantasticos premios.',
- data: '{" item_id" :'+user+'," item_type" :" plant" }'
- } ,
- function ( response) {
- if ( response & & response.request_ids) {
- alert( 'Tus invitaciones han sido enviadas, tus amigos recibiran una notificacion para subir a tu bus. Recueda que estas participando cuando tengas 20 pasajeros en el bus.') ;
- } else {
- //Do something if they don't send it.
- }
- } ) ;
- }
- //Rescatando datos desde php
- if( isset( $_REQUEST[ 'request_ids'] ) ) {
- // Requesting an application token
- $token_url =" https://graph.facebook.com/oauth/access_token?" .
- " client_id=" . $fbconfig[ 'appid' ] .
- " & client_secret=" . $fbconfig[ 'secret'] .
- " & grant_type=client_credentials" ;
- $app_token = file_get_contents( $token_url) ;
- // You may have more than one request, so it's better to loop
- $requests = explode( ',',$_REQUEST[ 'request_ids'] ) ;
- foreach( $requests as $request_id) {
- // Get the request details using Graph API
- $request_content = json_decode( file_get_contents( " https://graph.facebook.com/$request_id?$app_token" ) , TRUE) ;
- // An example of how to get info from the previous call
- $from_id = $request_content[ 'from'] [ 'id'] ;
- $to_id = $request_content[ 'to'] [ 'id'] ;
- // An easier way to extract info from the data field
- extract( json_decode( $request_content[ 'data'] , TRUE) ) ;
- // Now that we got the $item_id and the $item_type, process them
- // Or if the recevier is not yet a member, encourage him to claims his item (install your application)!
- $redirect_from_app = $fbconfig[ 'appUrl'] . " & app_data=https://www.songbingjia.com/android/" . $item_id;
- $loginUrl = $facebook-> getLoginUrl( array( 'scope' => 'email,publish_stream', 'redirect_uri' => $redirect_from_app) ) ;
- // When all is done, delete the requests because Facebook will not do it for you!
- //$deleted = file_get_contents(" https://graph.facebook.com/$request_id?$app_token& method=delete" ); // Should return true on success
- }
- }
推荐阅读
- Apprequest,pasar parametros e invitar朋友,facebook
- 在android中拥有sqlite数据库
- Android(谷歌地图标记)
- Android(以编程方式删除标题/通知栏)
- 将Apple.plist文件从XML/binary转换为
- Android简单警报
- PhoneGap项目的Android元视口标记
- 一键构建PhoneGap构建到Android
- Android检查服务是否正在运行