AccessKey

Sep 13, 2008 at 8:22 PM
I'm returing the list of documents to a GridView and then injecting the API javascript for the Viewer when a row is selected.

According to the API docs I need the AccessKey for this: http://www.scribd.com/publisher/api?method_name=Javascript+API

I see that this library is returns the AccessKey to the GridView, but it is always blank. When I inject the javascript with the AccessKey I see the Viewer with 'Access Key Invalid'.

    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
        try
        {
            int intDocumentId = Convert.ToInt32(GridView1.SelectedRow.Cells[0].Text);
            string strAccessKey = GridView1.SelectedRow.Cells[3].Text;

            StringBuilder sb = new System.Text.StringBuilder();
            sb.Append("<script language='javascript'>");
            sb.Append("var scribd_doc = scribd.Document.getDoc(" + intDocumentId.ToString() + ", '" + strAccessKey + "');");
            sb.Append("scribd_doc.addParam('height', 600);");
            sb.Append("scribd_doc.addParam('width', 400);");
            sb.Append("scribd_doc.write('embedded_flash');<");
            sb.Append("/script>");

            Type t = this.GetType();
            if (!ClientScript.IsClientScriptBlockRegistered(t, "ScribdScript"))
                ClientScript.RegisterStartupScript(t, "ScribdScript", sb.ToString());

        }
        catch (Exception Ex)
        {
            lblError.Text = Ex.Message;
        }
    }

Is this because the Scribd document isn't mine? I'm runnng a search with the following:

    protected void SearchDocs()
    {
        Scribd.Net.Search.Criteria mySearchCriteria = new Scribd.Net.Search.Criteria();
        mySearchCriteria.Query = txtSearch.Text;
        mySearchCriteria.Scope = Scribd.Net.SearchScope.All;
        mySearchCriteria.MaxResults = 100;
        mySearchCriteria.StartIndex = 1;

        try
        {
            Scribd.Net.Search.Result mySearchResult = Scribd.Net.Search.Find(mySearchCriteria);

            GridView1.DataSource = mySearchResult.Documents;
            GridView1.DataBind();
        }
        catch (Exception Ex)
        {
            lblError.Text = Ex.Message;
        }
    }

Coordinator
Sep 14, 2008 at 1:57 PM

That's the reason.  From the Scribd API: (http://www.scribd.com/publisher/api?method_name=docs.search)

string</TYPE> <NAME>access_key</NAME> <TEXT>The access_key allows you to embed a document on an external site. This parameter will only be provided if scope is set to "user".</TEXT>



- Paul