2012-08-31 2 views
0

난 내 페이스 북 공유 scritp이 : 내가 "이름", "링크", "그림"의 값을 얻으려면,방법 데이터베이스에서 값을 얻고, 자바 스크립트 함수 내부에 삽입하는

<script> 
    $(document).ready(function(){ 

     $('#share_button').click(function(e){ 
      e.preventDefault(); 
      FB.ui(
      { 
       method: 'feed', 
       name: 'This is the content of the "name" field.', 
       link: ' http://www.hyperarts.com/', 
       picture: 'http://www.hyperarts.com/external-xfbml/share-image.gif', 
       caption: 'This is the content of the "caption" field.', 
       description: 'This is the content of the "description" field, below the caption.', 
       message: '' 
      }); 
     });  

    }); 
    </script> 

을하지만, 및 다른 데이터베이스에서, 아마도 간단한 액세스 mbd 파일. 이 데이터베이스와 연결을 위해 Classic ASP를 사용할 것입니다 ...

어떻게 할 수 있습니까?

+0

과 같은 라이브러리를 찾으십시오.이 데이터베이스는 어디에 위치해 있습니까? 내 페이지의 동일한 폴더에 – Aesthete

+0

... 또는 폴더 "데이터베이스"를 caled ... 내 생각 엔 ... 내 생각 엔 ... – Preston

답변

0

데이터베이스에서 필요한 값을 읽고 JSON 형식으로 출력하는 서버 측 스크립트 (예 : php/mysql 또는 asp.net 등 사용)를 작성한 다음 ajax를 사용하여 서버에서 cherrypy

import cherrypy 
import json 

names = ['Bob'] // List of names. You call fill this from a DB 
class BasicServer: 
    @cherrypy.expose 
    def names(self): 
     return json.dumps(names) // Returns a JSON list of names from the DB. 

cherrypy.quickstart(BasicServer()) 

정말, 정말 기본적인 요청을 사용하여, 정말 간단한 파이썬 서버 스크립트의 JSON 출력을 얻을 정말 당신의 FB 객체

0

을 만들 응답 값을 사용합니다.

$('#share_button').click(function(e){ 
    e.preventDefault(); 
    var names = null; 
    // Request all the data you want from the server. 
    $.when($.get('serverAddress/names', function(data) { names = data; })) 
     // When all your requests are done, call your FB.ui function. 
     .done(FB.ui({name: names[0]}); // Just selects the first name ('bob') 
} 

템플릿 엔진은 일종의 템플릿 엔진입니다. 이렇게하면 페이지에 데이터 가 미리 기입되어으로 표시 될 수 있습니다. 여기의 예제는 파이썬이므로 MAKO 또는 mustache

+0

대답 주셔서 감사합니다,하지만 난 값을 얻으려면 클래식 ASP를 사용하여 데이터베이스에서. 나는 "파이썬"을 모른다. ... :) – Preston