<?xml version="1.0" encoding="utf-8"?>
<service name="facebook"
         version="$Id: facebook.xml 23055 2010-07-21 21:31:50Z justin $"
         xmlns="http://www.flock.com/web-detective#">

  <strings>
    <string name="domains" value="facebook.com"/>
    <string name="maxStatusLength" value="420"/>    
    <string name="userprofile">
      <![CDATA[http://www.facebook.com/profile.php?id=%accountid%]]>
    </string>
    <string name="inviteFriendsURL">
      <![CDATA[http://www.facebook.com/invite.php]]>
    </string>
    <string name="friendprofile">
      <![CDATA[http://www.facebook.com/profile.php?id=%accountid%]]>
    </string>
    <string name="friendPoke">
      <![CDATA[newtab:http://www.facebook.com/poke.php?id=%friendid%]]>
    </string>
    <string name="friendMessage">
      <![CDATA[newtab:http://www.facebook.com/inbox/?compose&id=%friendid%]]>
    </string>
    <string name="friendWallPost">
      <![CDATA[newtab:http://www.facebook.com/wallpost.php?id=%friendid%]]>
    </string>
    <string name="friendShareLink" 
            value="method:shareWithFriend" />
    <string name="friendViewProfile">
      <![CDATA[newtab:http://www.facebook.com/profile.php?id=%friendid%]]>
    </string>
    <string name="friendGiveGift">
      <![CDATA[newtab:http://www.facebook.com/giftshop.php?to=%friendid%]]>
    </string>
    <string name="friendStatusComment"
            value="method:friendAction:statusComment" />
    <string name="statusCommentURL">
      <![CDATA[http://www.facebook.com/profile.php?id=%friendid%&v=feed&story_fbid=%storyid%]]>
    </string>
    <string name="friendShareFlock" 
            value="method:shareFlock" />

    <!-- API Strings -->

    <string name="apiAppID">
      <![CDATA[2372251387]]>
    </string>
    <string name="apiAppKey">
      <![CDATA[7fa235c847b11f157e12586c86660f47]]>
    </string>
    <string name="apiAppSecret">
      <![CDATA[645e5d3f9fde64b65a1a12744486b093]]>
    </string>

    <string name="apiAccessTokenRE">
      <![CDATA[#access_token=(.+?)(&|$)]]>
    </string>
    <string name="apiPermissionsBody">
      <![CDATA[post_form_id=%post_form_id%&fb_dtsg=%fb_dtsg%&app_id=%app_id%&display=popup&next=%next%&client_id=%app_id%&redirect_uri=%redirect%&type=user_agent&scope=%perms%&cancel_url=%cancel%&return_session=1&perms=%perms%&from_post=1&__uiserv_method=permissions.request&grant_clicked=Allow]]>
    </string>
    <string name="apiOldPermissionsBody">
      <![CDATA[charset_test=%E2%82%AC%2C%C2%B4%2C%E2%82%AC%2C%C2%B4%2C%E6%B0%B4%2C%D0%94%2C%D0%84&fb_dtsg=%fb_dtsg%&grant_perm=1&next=%next%&api_key=%apikey%&req_perms=%perms%&auth_token=&post_form_id=%post_form_id%&cancel_url=%cancel%]]>
    </string>

    <string name="facebookApi_PERM_URL">
      <![CDATA[http://www.facebook.com/authorize.php?api_key=%apikey%&ext_perm=%perm%&v=1.0]]>
    </string>
    <string name="facebookApi_PERM_BODY">
      <![CDATA[charset_test=%E2%82%AC%2C%C2%B4%2C%E2%82%AC%2C%C2%B4%2C%E6%B0%B4%2C%D0%94%2C%D0%84&grant_perms=1&app_id=2372251387&perms=1&post_form_id=%postformid%&fb_dtsg=%fb_dtsg%]]>
    </string>
    <string name="facebookApi_EDITAPP_URL">
      <![CDATA[http://www.facebook.com/editapps.php?v=all]]>
    </string>
    <string name="facebookApi_EDITAPP_AJAX">
      <![CDATA[http://www.facebook.com/ajax/edit_app_settings.php]]>
    </string>
    <string name="facebookApi_ADDAPP">
      <![CDATA[profile=1&item=box&action=add&app_id=%appid%&box_tab=3&post_form_id=%postformid%]]>
    </string>
    <string name="facebookApi_FULLNEWS">
      <![CDATA[publishing=1&setting=5&app_id=%appid%&post_form_id=%postformid%]]>
    </string>

    <!-- // Extended Permissions:
      http://developers.facebook.com/docs/authentication/permissions
    -->
    <string name="apiExtendedPermissions" 
            value="publish_stream,read_stream,user_activities,friends_activities,user_events,friends_events,user_photos,friends_photos,user_status,friends_status,read_friendlists,read_requests" />

    <!-- Notification URLs -->

    <string name="meMessages_URL">
      <![CDATA[http://www.facebook.com/inbox/]]>
    </string>
    <string name="mePokes_URL">
      <![CDATA[http://www.facebook.com/pokes.php]]>
    </string>
    <string name="meFriendRequests_URL">
      <![CDATA[http://www.facebook.com/reqs.php#friend]]>
    </string>
    <string name="meGroupRequests_URL">
      <![CDATA[http://www.facebook.com/reqs.php#group]]>
    </string>
    <string name="meEventRequests_URL">
      <![CDATA[http://www.facebook.com/reqs.php#event]]>
    </string>

    <string name="sendMessage">
      <![CDATA[http://www.facebook.com/message.php?id=%friendid%&subject=%subject%&msg=%message%]]>
    </string>

    <string name="postLink">
      <![CDATA[http://www.facebook.com/share.php?u=%url%&src=sc]]>
    </string>

    <!-- Dropable Fields XPaths -->

    <string name="dndXPathFields">
      <![CDATA[messageBodyXPath,text/unicode;publisherTextXPath,text/unicode;publisherLinkXPath,text/unicode;wallTextXPath,text/unicode;commentXPath,text/unicode;newWallTextXPath,text/unicode;statusCommentXPath,text/unicode;newLinkTextXPath,text/unicode;newPostLinkShareTextAreaXPath,text/unicode;newWriteNoteXPath,text/unicode]]>
    </string>
    <string name="messageBodyXPath">
      <![CDATA[//textarea[@id="message"]]]>
    </string>
    <string name="publisherTextXPath">
      <![CDATA[//textarea[contains(@id,"_input")]]]>
    </string>
    <string name="publisherLinkXPath">
      <![CDATA[//div[contains(@class,"UIComposer_Attachment_Visible")]//form//input[contains(@id,"_URL")]]]>
    </string>
    <string name="wallTextXPath">
      <![CDATA[//textarea[@id="wall_text"]]]>
    </string>
    <string name="commentXPath">
      <![CDATA[//textarea[@id="comment"]]]>
    </string>
    <string name="newWallTextXPath">
      <![CDATA[//div[@id="composer_canvas"]//textarea[@id="2719290516_comment_text"]]]>
    </string>
    <string name="statusCommentXPath">
      <![CDATA[//textarea[contains(@id,"add_comment_text_")]]]>
    </string>
    <string name="newLinkTextXPath">
      <![CDATA[//div[@id="composer_canvas"]//div[@id="share_profile_composer"]//input[@id="the_link"]]]>
    </string>
    <string name="newPostLinkShareTextAreaXPath">
      <![CDATA[//dd[@id="dd_message_field"]/textarea[@id="sharer_popup_message"]]]>
    </string>
    <string name="newWriteNoteXPath">
      <![CDATA[//textarea[@id="note_content"]]]>
    </string>

    <!-- DND Helper XPaths -->

    <string name="newShareLinkPreviewButton">
      <![CDATA[//div[@id="composer_canvas"]//div[@id="share_profile_composer"]//input[@id="preview_button"]]]>
    </string>
    <string name="newShareLinkCommentArea">
      <![CDATA[//div[@id='share_profile_composer']//textarea[@id='2309869772_comment_text']]]>
    </string>
    <string name="newLinkFormXPath">
      <![CDATA[//div[@id="composer_canvas"]//div[@id="share_profile_composer"]]]>
    </string>
    <string name="newLinkXPathArea">
      <![CDATA[//div[@id="profile_composer"]//li[@id="composer_2309869772"]]]>
    </string>
        <string name="newLinkXPathLink">
      <![CDATA[//div[@id="profile_composer"]//li[@id="composer_2309869772"]//a]]>
    </string>
    <string name="newWriteNoteTitleXPath">
      <![CDATA[//input[@id="title"]]]>
    </string>
    <string name="publisherLinkAttachXPath">
      <![CDATA[//div[contains(@class,"UIComposer_Attachment_Visible")]//form//input[contains(@class,"UIComposer_Attachment_Button")]]]>
    </string>
    <string name="publisherLinkButtonXPath">
      <![CDATA[//ul[contains(@class,"UIComposer_AttachmentList") and @style[not(contains(.,"opacity: 0"))]]/li[2]/a]]>
    </string>

    <string name="homePageURL" locale="default">
      <![CDATA[http://www.facebook.com/]]>
    </string>

    <string name="loginURL" locale="default">
      <![CDATA[http://www.facebook.com/login.php]]>
    </string>

    <string name="facebookApiKey">
      <![CDATA[7fa235c847b11f157e12586c86660f47]]>
    </string>
    <string name="facebookApiSecretHash">
      <![CDATA[645r5q3s9sqr64o65n1n12744486o093]]>
    </string>
  </strings>

  <sessioncookies>
    <cookie host=".facebook.com" name="c_user" path="/"/>
    <cookie host=".facebook.com" name="ljsession" path="/"/>
  </sessioncookies>

  <detect type="loggedin">
    <url domain="facebook.com"/>
    <regexp><![CDATA[/^Env={user:([0-9]+),/]]></regexp>
    <xpath><![CDATA[//form[@id="logout_form"][@action="/logout.php"]]]></xpath>
  </detect>

  <detect type="loggedin">
    <url domain="facebook.com"/>
    <regexp><![CDATA[/^Env={user:([0-9]+),/]]></regexp>
    <xpath><![CDATA[//ul[contains(@id,"Nav")]//a[contains(@href,"facebook.com/logout.php")]]]></xpath>
  </detect>

  <detect type="loggedin">
    <url domain="facebook.com"/>
    <xpath><![CDATA[//div[@id="navigator"]//li/a/@href[contains(.,"logout")]]]></xpath>
  </detect>

  <detect type="loggedin">
    <url domain="facebook.com"/>
    <xpath><![CDATA[//div[@id="fb_menu_profile"]]]></xpath>
  </detect>

  <detect type="loggedin">
    <url domain="facebook.com"/>
    <xpath><![CDATA[//li[@id="fb_menu_profile"]]]></xpath>
  </detect>

  <detect type="loggedin">
    <url domain="facebook.com"/>
    <xpath><![CDATA[//div[@id="presence"]]]></xpath>
  </detect>

  <detect type="loggedoutcookies">
    <cookie nomatch="true" host=".facebook.com" name="xs"/>
    <cookie nomatch="true" host=".facebook.com" name="c_user"/>
  </detect>

  <detect type="loggedout">
    <xpath><![CDATA[//div[@id="menubar_container"]//form[@id="login_form"]]]></xpath>
  </detect>

  <detect type="loggedout">
    <xpath><![CDATA[//div[@id="menubar_container"]//form[@id="menubar_login"]]]></xpath>
  </detect>

  <detect type="loggedout">
    <url domain="facebook.com"/>
    <xpath><![CDATA[//div[@id="navigator"]//li/a/@href[contains(.,"login")]]]></xpath>
  </detect>

  <detect type="loggedout">
    <url domain="facebook.com">
      <path contains="login.php" />
    </url>
    <xpath><![CDATA[//div[@id="loginform"]//input[@id="email"]]]></xpath>
  </detect>

  <detect type="loggedout">
    <url domain="facebook.com" />
    <xpath><![CDATA[//div[@id="squicklogin"]//form[@name="loginform"]]]></xpath>
  </detect>

  <detect type="loggedout">
    <url domain="facebook.com">
      <path contains="/people/" />
    </url>
    <xpath>
      <![CDATA[//form[@id="menubar_login"]]]>
    </xpath>
  </detect>

  <detect type="accountinfo">
    <url domain="facebook.com"/>
    <regexp re1="accountid"><![CDATA[/^Env={user:([0-9]+),/]]></regexp>
  </detect>

  <detect type="accountinfo">
    <url domain="facebook.com"/>
    <xpath name="accountid" extract="attribute:value">
      <![CDATA[//input[@id="user"]]]>
    </xpath>
  </detect>

  <detect type="accountinfo">
    <url domain="facebook.com"/>
    <regexp re1="accountid">
      <![CDATA[/profile\.php\?id=([0-9]+)[^>]+ class=\"profile_nav_link\"/]]>
    </regexp>
  </detect>

  <detect type="accountinfo">
    <url domain="facebook.com"/>
    <xpath extract="attribute:onfocus">
      <![CDATA[//div[@id="universal_search_input"]/input[@id="q"]]]>
      <regexp re1="accountid">
        <![CDATA[/u=([0-9]+)/]]>
      </regexp>
    </xpath>
  </detect>

  <detect type="accountinfo">
    <url domain="facebook.com" />
    <xpath extract="attribute:href">
      <![CDATA[//div[@id="presence"]//div[contains(@class,"profile_status")]/a[contains(@href,"profile.php")]]]>
      <regexp re1="accountid">
        <![CDATA[/id=([0-9]+)/]]>
      </regexp>
    </xpath>
  </detect>

  <detect type="accountinfo">
    <url domain="facebook.com"/>
    <xpath>
      <![CDATA[//div[@id="fb_menu_profile"]//a/@href]]>
      <regexp re1="accountid">
        <![CDATA[/profile\.php\?id=([0-9]+)/]]>
      </regexp>
    </xpath>
  </detect>

  <detect type="accountinfo">
    <url domain="facebook.com"/>
    <xpath>
      <![CDATA[//li[@id="fb_menu_profile"]//a/@href]]>
      <regexp re1="accountid">
        <![CDATA[/profile\.php\?id=([0-9]+)/]]>
      </regexp>
    </xpath>
  </detect>

  <detect type="accountinfo">
    <url domain="facebook.com"/>
    <xpath>
      <![CDATA[//li[@id="fb_menu_account"]//a/@href]]>
      <regexp re1="accountid">
        <![CDATA[/profile\.php\?id=([0-9]+)/]]>
      </regexp>
    </xpath>
  </detect>

  <detect type="accountinfo">
    <url domain="facebook.com"/>
    <xpath>
      <![CDATA[//div[@id="js_buffer"]/script/text()]]>
      <regexp re1="accountid">
        <![CDATA[/new fbPresence\("([0-9]+)"/]]>
      </regexp>
    </xpath>
  </detect>

  <detect type="login">
    <url domain="facebook.com"/>
    <form>
      <field extractas="username"
             fieldid="email"
             tagname="input"
             type="text" />
      <field extractas="password"
             fieldid="pass"
             tagname="input"
             type="password" />
    </form>
  </detect>

  <detect type="signup">
    <url domain="facebook.com" />
    <form>
      <field extractas="username"
             fieldid="reg_email__"
             tagname="input"
             type="text" />
      <field extractas="password"
             fieldid="reg_passwd__"
             tagname="input"
             type="password"/>
    </form>
  </detect>

  <detect type="permission">
    <regexp re1="postFormId">
      <![CDATA[/name="post_form_id"\svalue="([a-zA-Z0-9]+)"/]]>
    </regexp>
    <regexp re1="fb_dtsg">
      <![CDATA[/name="fb_dtsg"\svalue="(.+?)"/]]>
    </regexp>
  </detect>

  <detect type="permission">
    <regexp re1="postFormId">
      <![CDATA[/name="post_form_id"\svalue="([a-zA-Z0-9]+)"/]]>
    </regexp>
  </detect>

  <!-- friend actions -->

  <detect type="statusCommentLink">
    <xpath name="comment_link" extract="this">
      <![CDATA[//span[@class="action_links_bottom"]/a]]>
    </xpath>
  </detect>

  <detect type="statusComment">
    <xpath name="comment" extract="this">
      <![CDATA[//textarea[contains(@id,"add_comment_text_")]]]>
    </xpath>
  </detect>

  <!-- media discovery -->

  <detect type="person">
    <!-- http://www.facebook.com/profile.php?id=123456789&ref=nf -->
    <url domain="facebook.com">
      <regexp re1="userid">
        <![CDATA[/profile\.php.+id=([0-9]+)/]]>
      </regexp>
    </url>
  </detect>

  <detect type="person">
    <!-- http://www.facebook.com/flocktest -->
    <url domain="facebook.com" />
    <xpath extract="attribute:href">
      <![CDATA[//div[@id="left_column"]/div[@id="profileimage"]/a[contains(@href,"album.php?profile=1")]]]>
      <regexp re1="userid">
        <![CDATA[/id=([0-9]+)/]]>
      </regexp>
    </xpath>
  </detect>

  <detect type="photo">
    <!-- http://www.facebook.com/photo.php?pid=752998&id=737755410 -->
    <url domain="facebook.com">
      <regexp re1="userid">
        <![CDATA[/photo\.php.+id=([0-9]+)/]]>
      </regexp>
    </url>
  </detect>

  <detect type="tagged">
    <!-- http://www.facebook.com/photo_search.php?id=511664568 -->
    <url domain="facebook.com">
      <regexp re1="userid">
        <![CDATA[/photo_search\.php.+id=([0-9]+)/]]>
      </regexp>
    </url>
  </detect>

  <!-- Old Authentication and permissions -->

  <!-- Redirect to the Terms of Service -->
  <detect type="apiAuth0">
    <conditions>
      <regexp><![CDATA[/<script>window.location.href = /]]></regexp>
    </conditions>
    <results>
      <regexp re1="authUrl"><![CDATA[/<script>window.location.href = "(.+?)"/i]]></regexp>
    </results>
  </detect>

  <detect type="apiAuth0">
    <conditions>
      <regexp><![CDATA[/<script>window.location.replace/]]></regexp>
    </conditions>
    <results>
      <regexp re1="authUrl"><![CDATA[/<script>window.location.replace\("(.+?)"/i]]></regexp>
    </results>
  </detect>

  <!-- "Flock is requesting access." -->
  <detect type="apiAuth1">
    <conditions>
      <regexp><![CDATA[/id="agree" name="agree"/]]></regexp>
    </conditions>
    <results>
      <regexp re1="postUrl"><![CDATA[/<div id="tosform"><form method="post" action="(.+?)"/i]]></regexp>
      <regexp re1="formId"><![CDATA[/name="post_form_id" value="(.+?)"/]]></regexp>
    </results>
  </detect>

  <!-- "You've granted access to Flock previously. Flock is requesting continued access." -->
  <detect type="apiAuth1">
    <conditions>
      <regexp><![CDATA[/div id="confirm_button" class="confirm_button confirming_grant"/]]></regexp>
      <regexp><![CDATA[/<form method="post" action=".+?" name="confirm_grant_form"/i]]></regexp>
    </conditions>
    <results>
      <regexp re1="postUrl"><![CDATA[/<form method="post" action="(.+?)" name="confirm_grant_form"/i]]></regexp>
      <regexp re1="formId"><![CDATA[/name="post_form_id" value="(.+?)"/]]></regexp>
    </results>
  </detect>

  <detect type="apiAuth1">
    <conditions>
      <regexp><![CDATA[/div id="confirm_button" class="confirm_button confirming_grant"/]]></regexp>
      <regexp><![CDATA[/<form method="post" action=".+?" id="confirm_grant_form"/i]]></regexp>
    </conditions>
    <results>
      <regexp re1="postUrl"><![CDATA[/<form method="post" action="(.+?)" id="confirm_grant_form"/i]]></regexp>
      <regexp re1="formId"><![CDATA[/name="post_form_id" value="(.+?)"/]]></regexp>
    </results>
  </detect>

  <detect type="apiAuth2">
    <regexp><![CDATA[/logout.php/]]></regexp>
  </detect>

  <!-- OAuth rules -->

  <detect type="apiOAuthOldGrant">
    <conditions>
      <regexp><![CDATA[/<form method="post" action=".+?" (id|name)="confirm_grant_form"/i]]></regexp>
    </conditions>
    <results>
      <regexp re1="postUrl"><![CDATA[/<form method="post"\saction="(.+?)" (id|name)="confirm_grant_form"/i]]></regexp>
      <regexp re1="formId"><![CDATA[/name="post_form_id"\svalue="(.+?)"/]]></regexp>
      <regexp re1="fb_dtsg"><![CDATA[/name="fb_dtsg"\svalue="(.+?)"/]]></regexp>
      <regexp re1="next"><![CDATA[/name="next"\svalue="(.+?)"/]]></regexp>
      <regexp re1="cancel"><![CDATA[/name="cancel_url"\svalue="(.+?)"/]]></regexp>
    </results>
  </detect>

  <detect type="apiOAuthOldPermissions">
    <regexp><![CDATA[/<form method="post" action=".+?" (id|name)="permissions_form"/i]]></regexp>
  </detect>

  <detect type="apiOAuthNewPermissions">
    <conditions>
      <regexp><![CDATA[/<input type="hidden" name="scope"/]]></regexp>
      <regexp><![CDATA[/name="__uiserv_method" value="permissions.request"/i]]></regexp>
    </conditions>
    <results>
      <regexp re1="postUrl"><![CDATA[/<form id="uiserver_form" action="(.+?)"\smethod="post"/i]]></regexp>
      <regexp re1="formId"><![CDATA[/name="post_form_id"\svalue="(.+?)"/]]></regexp>
      <regexp re1="fb_dtsg"><![CDATA[/name="fb_dtsg"\svalue="(.+?)"/]]></regexp>
      <regexp re1="next"><![CDATA[/name="next"\svalue="(.+?)"/]]></regexp>
      <regexp re1="cancel"><![CDATA[/name="cancel_url"\svalue="(.+?)"/]]></regexp>
    </results>
  </detect>

  <detect type="apiOAuthLoggedOut">
    <regexp><![CDATA[/<form method="post" action=".+?" (id|name)="login_form"/i]]></regexp>
  </detect>

  <detect type="apiOAuthSuccess">
    <regexp><![CDATA[/<title>Success<\/title>/]]></regexp>
  </detect>

  <detect type="apiOAuthRedirect">
    <conditions>
      <regexp><![CDATA[/<script>window.location.replace\(".+?"\);<\/script>/]]></regexp>
    </conditions>
    <results>
      <regexp re1="redirectUrl"><![CDATA[/<script>window.location.replace\("(.+?)"\);<\/script>/]]></regexp>
    </results>
  </detect>

  <!-- The user has manually accepted and reached the Success page -->
  <detect type="apiOAuthSuccessPage">
    <url domain="facebook.com">
      <regexp re1="access_token">
        <![CDATA[/login_success\.html#access_token=(.+?)(&|$)/]]>
      </regexp>
    </url>
  </detect>
</service>
