1

저는 Facebook의 API를 사용하여 인스턴트 기사를 만드는 WordPress 플러그인을 개발해 왔습니다. (여기서 SDK 버전 5.3.1을 사용하고 있습니다 : https://github.com/facebook/php-graph-sdk/tree/5.4) 많은 사용자 정의 필드가 필요하므로 기존 플러그인을 사용하는 대신 새로운 플러그인을 사용해야합니다. Vagrant/VirtualBox Linux 서버를 사용하여 로컬 컴퓨터에서 개발했으며 게시 도구> 인스턴트 기사> 개발 관련 기사에서 Facebook의 목록에 나타난 Instant Article을 성공적으로 인증하고 만들 수있었습니다.Facebook 인스턴트 기사 : 그래프 API로 기사 만들기

라이브 웹 서버에 동일한 코드를 배포하여 테스트를 계속했습니다. 인증은 성공적이지만 서버에서 기사를 게시하려고 시도하면 Instant Article이 생성되지 않고 Facebook의 목록에 나타나지 않습니다.

수수께끼 같은 것은 두 시도의 응답이 거의 동일하다는 것입니다. 한 가지 차이점은 accessToken 값이며 {access_token}으로 표시했습니다. 응답 간의 다른 차이점은 {different}입니다.

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의 제안에 자신의 의견에 내가 할 수 있었다 문제의 원인을 발견 할 수 있습니다. get the article import status에 요청을 한 후, 나는 응답이 오류 메시지가 발견, 내가 마크 업에 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}"}" 

을 내 로컬 있도록 도메인 이름 테스트는 올바른 "청구 된"도메인 이름으로 바뀝니다. 코드를 새 도메인에 배포했기 때문에이 대체는 발생하지 않았으며 Facebook은 마크 업에서 잘못된 "소유권이 주장되지 않은"도메인을 보았습니다.

대체 할 이름 배열에 새 도메인 이름을 추가함으로써 "claim"도메인이있는 Instant Articles에 마크 업을 보낼 수있었습니다. 내 기사가 성공적으로 만들어졌습니다.

대단히 감사합니다. CBroe, 나는 내 마음을 잃고있었습니다.

관련 문제