1

こんにちは、

現在、Facebook の登録プラグインを使用しており、フィールドのデフォルト値をテキスト タイプに設定します。

しかし、それが可能かどうかはわかりませんか?PHP とプラグインでテキスト フィールドのデフォルト値を設定する方法は? ご協力いただきありがとうございます !

<iframe src="https://www.facebook.com/plugins/registration?
         client_id=APP_ID&
         redirect_uri=[...]&
         fields=[{'name':'name'},
                {'name':'last_name'},
                {'name':'first_name'},
                {'name':'birthday'},
                {'name':'gender'},
                {'name':'email'},
                {'name':'telephone', 'description':'T\u00e9l\u00e9phone', 'type':'text', 'default':'sith'},
                {'name':'portable', 'description':'Portable (facultatif)', 'type':'text','no_submit':true},
                {'name':'fax', 'description':'Fax (facultatif)', 'type':'text','no_submit':true},
                {'name':'adresse','description':'Adresse','type':'text','default':'truc'},
                {'name':'adresse_suite','description':'Adresse (suite)','type':'text','no_submit':true},
                {'name':'code_postal','description':'Code postal','type':'text'},
                {'name':'ville','description':'Ville','type':'text'},
                {'name':'pays','description':'Pays','type':'select',
                'options':[...]},
                {'name':'password'},
                {'name':'captcha'},
                {'name':'abonnement','description':'Re\u00e7evoir la Newsletter','type':'checkbox'},
                {'name':'stop_pub','description':'Re\u00e7evoir des offres marketing et bons d\'achat','type':'checkbox'},
                {'name':'offre_sortir','description':'Re\u00e7evoir des bons plans Sortir Malin dans votre r\u00e9gion','type':'checkbox'},
                {'name':'offre_partenaire','description':'Offres publicitaires de la part d\'autres partenaires','type':'checkbox'}]"
            scrolling="auto"
            frameborder="no"
            style="border:none"
            allowTransparency="true"
            width="100%"
            height="850"
            onvalidate="validate">
    </iframe>

私の悪い英語でごめんなさい、私はフランス人です!=)

4

1 に答える 1

0

ドキュメントによると、パラメータはフィールドとフィールドにdefaultのみ適用され、テキスト フィールドには適用されません):type:selecttype:checkbox

参考までに: デフォルトは、選択フィールドとチェックボックス フィールドにのみ適用されます http://o7.no/K5jDj0

ただし、私なら、送信したいオプションの完全な配列を作成し、タグjson_encode内で直接定義するのではなく、一度にそれらを作成します。次に例を示します。<iframe>

<?php
$regOptions = array(
    array('name' => 'name'),
    array('name' => 'last_name'),
    array('name' => 'birthday'),
    //the other fields
    array('name' => 'telephone',
          'description' => 'T\u00e9l\u00e9phone',
          'type' => 'text'
    ),
    //the other fields  
);
?>

//Then in your iframe:
<iframe src="https://www.facebook.com/plugins/registration?
     client_id=APP_ID&
     redirect_uri=[...]&

     fields="<?= urlencode(json_encode($regOptiosn)); ?>

     scrolling="auto"
     frameborder="no"
     style="border:none"
     allowTransparency="true"
     width="100%"
     height="850"
     onvalidate="validate">
</iframe>

これにより、不安定な文字列のためにブラウザがリクエストを台無しにすることを恐れずに、フィールドを活用json_encodeして定義することができます。urlencode

一部のフィールドがオプションまたは必須であることについては、ドキュメントの高度な登録ボタン機能を確認してください。FB には、フォームを検証するいくつかの方法が用意されています。これにより、フィールドが無効な場合や入力されていない場合にフォームの送信をブロックできます。

于 2012-05-21T13:07:50.220 に答える