万年素人からHackerへの道

万年素人がHackerになれるまで殴り書きするぜ。

  • ・資産運用おすすめ
    10万円は1000円くらい利益
    資産運用ブログ アセマネ
    • ・寄付お願いします
      YENTEN:YYzNPzdsZWqr5THWAdMrKDj7GT8ietDc2W
      BitZenny:ZfpUbVya8MWQkjjGJMjA7P9pPkqaLnwPWH
      c0ban:8KG95GXdEquNpPW8xJAJf7nn5kbimQ5wj1
      Skycoin:KMqcn7x8REwwzMHPi9fV9fbNwdofYAWKRo

    Titanium のFacebookモジュールを使う

    ・tiapp.xml

    コメントアウトして置き換える。

        <!--modules/-->
        <modules>
            <!-- Add the appropriate line(s) to your modules section -->
            <module platform="android">facebook</module>
            <module platform="iphone">facebook</module>
    	</modules>
    

    alloy.coffee
    JavaScriptを使う人はalloy.jsをいじる。

    Alloy.Globals.Facebook = require('facebook')

    ・index.jade
    →これで実際のボタンが配置される。

    Alloy
        Window.container
            LoginButton#fbButton(ns="Alloy.Globals.Facebook") 

    〜(ns="Ti.Facebook") のもあるので注意!
    おそらく古いモジュール?

    ・index.coffeee

    fb = Alloy.Globals.Facebook
    fb.appid = "265040643542216"
    fb.permissions = ['publish_stream', 'create_event', 'email']
    $.fbButton.style = fb.BUTTON_STYLE_WIDE
    fb.addEventListener('login', (e)->
      if e.success
        fb.requestWithGraphPath('me', {}, 'GET', (e)->
          if e.success
            # alert(e.result)
            response = JSON.parse(e.result)
            email = response.email
            name = response.name
            gender = response.gender
            alert(name+' '+email+' '+gender)
            alert('Logged in Successfully')
          else if (e.error)
            alert(e.error)
          else
            alert('Unknown response')
        )
    )

    で配置とクリック時の処理。
    ※addEventListener('click', (e)->ではないので注意

    ボタンを押した時の処理は他に書く。

    参考URL: http://stackoverflow.com/questions/12605031/titanium-facebook-authorize-an-error-occurred