1

FacebookのAPIを使用してインスタントアーティクルを作成するWordPressプラグインを開発しています。 (私はここからSDKバージョン5.3.1を使用しています:https://github.com/facebook/php-graph-sdk/tree/5.4)多くのカスタムフィールドを必要とするため、既存のプラグインを使用する代わりに新しいプラグインを使用する必要があります。私はVagrant/VirtualBoxのLinuxサーバーを使って自分のローカルマシンでそれを開発しました。そこから、インスタントアーティクルを認証して作成することができました。それは、パブリッシングツール>インスタントアーティクル>開発記事の中のFacebookのリストに現れました。Facebookインスタントアーティクル:グラフAPIを使用した記事の作成

ライブWebサーバーに同じコードをデプロイしてテストを続行しました。認証はまだ成功していますが、そのサーバーから記事を公開しようとすると、インスタントアーティクルは決して作成されず、Facebookのリストには表示されません。

困ったことは、両方の試行からの応答がほぼ同じように見えることです。 1つの違いはaccessTokenの値です。値は{access_token}とマークされています。私は{different}とマークした反応の間の他の違い。

誰かがなぜ成功したのか、もう1つはPHPやAPIレスポンスに明らかなエラーがなく失敗するのを誰も理解できますか?ローカルマシンを使用して

応答(成功):ライブサーバーを使用して

object(Facebook\FacebookResponse)#144 (6) { 
    ["httpStatusCode":protected]=> 
    int(200) 
    ["headers":protected]=> 
    array(13) { 
    ["Access-Control-Allow-Origin"]=> 
    string(1) "*" 
    ["Pragma"]=> 
    string(8) "no-cache" 
    ["Cache-Control"]=> 
    string(44) "private, no-cache, no-store, must-revalidate" 
    ["facebook-api-version"]=> 
    string(4) "v2.7" 
    ["Expires"]=> 
    string(29) "Sat, 01 Jan 2000 00:00:00 GMT" 
    ["Content-Type"]=> 
    string(31) "application/json; charset=UTF-8" 
    ["x-fb-trace-id"]=> 
    string(11) "{different}" 
    ["x-fb-rev"]=> 
    string(7) "{different}" 
    ["Vary"]=> 
    string(15) "Accept-Encoding" 
    ["X-FB-Debug"]=> 
    string(88) "{different}" 
    ["Date"]=> 
    string(29) "Wed, 19 Oct 2016 16:24:51 GMT" 
    ["Connection"]=> 
    string(10) "keep-alive" 
    ["Content-Length"]=> 
    string(2) "25" 
    } 
    ["body":protected]=> 
    string(25) "{"id":"{different}"}" 
    ["decodedBody":protected]=> 
    array(1) { 
    ["id"]=> 
    string(16) "{different}" 
    } 
    ["request":protected]=> 
    object(Facebook\FacebookRequest)#145 (9) { 
    ["app":protected]=> 
    object(Facebook\FacebookApp)#183 (2) { 
     ["id":protected]=> 
     string(16) "{app_id}" 
     ["secret":protected]=> 
     string(32) "{app_secret}" 
    } 
    ["accessToken":protected]=> 
    string(168) "{access_token}" 
    ["method":protected]=> 
    string(4) "POST" 
    ["endpoint":protected]=> 
    string(29) "/{some_endpoint_id}/instant_articles" 
    ["headers":protected]=> 
    array(1) { 
     ["Content-Type"]=> 
     string(33) "application/x-www-form-urlencoded" 
    } 
    ["params":protected]=> 
    array(3) { 
     ["development_mode"]=> 
     string(1) "1" 
     ["published"]=> 
     bool(false) 
     ["html_source"]=> 
     string(1600) "<html> ... </html>" 
    } 
    ["files":protected]=> 
    array(0) { 
    } 
    ["eTag":protected]=> 
    NULL 
    ["graphVersion":protected]=> 
    string(4) "v2.7" 
    } 
    ["thrownException":protected]=> 
    NULL 
} 

が応答(失敗):

object(Facebook\FacebookResponse)#107 (6) { 
    ["httpStatusCode":protected]=> 
    int(200) 
    ["headers":protected]=> 
    array(13) { 
    ["Access-Control-Allow-Origin"]=> 
    string(1) "*" 
    ["Pragma"]=> 
    string(8) "no-cache" 
    ["Cache-Control"]=> 
    string(44) "private, no-cache, no-store, must-revalidate" 
    ["facebook-api-version"]=> 
    string(4) "v2.7" 
    ["Expires"]=> 
    string(29) "Sat, 01 Jan 2000 00:00:00 GMT" 
    ["Content-Type"]=> 
    string(31) "application/json; charset=UTF-8" 
    ["x-fb-trace-id"]=> 
    string(11) "{different}" 
    ["x-fb-rev"]=> 
    string(7) "{different}" 
    ["Vary"]=> 
    string(15) "Accept-Encoding" 
    ["X-FB-Debug"]=> 
    string(88) "{different}" 
    ["Date"]=> 
    string(29) "Wed, 19 Oct 2016 16:02:08 GMT" 
    ["Connection"]=> 
    string(10) "keep-alive" 
    ["Content-Length"]=> 
    string(2) "24" 
    } 
    ["body":protected]=> 
    string(24) "{"id":"{different}"}" 
    ["decodedBody":protected]=> 
    array(1) { 
    ["id"]=> 
    string(15) "{different}" 
    } 
    ["request":protected]=> 
    object(Facebook\FacebookRequest)#106 (9) { 
    ["app":protected]=> 
    object(Facebook\FacebookApp)#126 (2) { 
     ["id":protected]=> 
     string(16) "{app_id}" 
     ["secret":protected]=> 
     string(32) "{app_secret}" 
    } 
    ["accessToken":protected]=> 
    string(164) "{access_token}" 
    ["method":protected]=> 
    string(4) "POST" 
    ["endpoint":protected]=> 
    string(29) "/{some_endpoint_id}/instant_articles" 
    ["headers":protected]=> 
    array(1) { 
     ["Content-Type"]=> 
     string(33) "application/x-www-form-urlencoded" 
    } 
    ["params":protected]=> 
    array(3) { 
     ["development_mode"]=> 
     string(1) "1" 
     ["published"]=> 
     bool(false) 
     ["html_source"]=> 
     string(1639) "<html> ... </html>" 
    } 
    ["files":protected]=> 
    array(0) { 
    } 
    ["eTag":protected]=> 
    NULL 
    ["graphVersion":protected]=> 
    string(4) "v2.7" 
    } 
    ["thrownException":protected]=> 
    NULL 
} 
+1

API経由で返されたIDの詳細をリクエストするとどうなりますか? – CBroe

答えて

1

私ができた彼のコメントでCBroeの提案のおかげで問題の原因を発見してください。私はその後、私の地元のように、インスタント条のマークアップを構築する私の機能では、私はマークアップにstr_replaceをしていた、ということが実現

["body":protected]=> 
    string(439) "{"errors":[{"level":"ERROR","message":"Unclaimed URL: The URL http:\/\/www.example.com\/my-article-url\/ has not been claimed for Instant Articles. Please check to make sure you have a URL registered for your page. For more information refer to URLs in the Publishing Articles section of the Instant Articles documentation."}],"status":"FAILED","id":"{some_id}"}" 

get the article import statusに要求を行った後、私は応答でこのエラーメッセージを見つけましたドメイン名をテストすることは、正しい "要求された"ドメイン名に置き換えられます。このコードを新しいドメインに導入して以来、この置き換えは起こっておらず、Facebookは誤ったマークが付いていないドメインを見つけました。

新しいドメイン名を置換する名前の配列に追加することで、マークされたアイテムをインスタントアーティクルに "claim"ドメインで送信することができました。私の記事は正常に作成されました!

非常にありがとうCBroe、私は私の心を失っていた。

関連する問題