Programming

그래프 API를 사용하여 주식 수를 얻는 방법

procodes 2020. 6. 23. 22:13
반응형

그래프 API를 사용하여 주식 수를 얻는 방법


PHP SDK와 더 이상 사용되지 않는 rest API를 사용하여 URL의 공유 수를 얻을 수 있지만 그래프 API를 사용하여 URL의 공유 수를 얻는 방법을 찾지 못했습니다.

알아낼 방법이 있습니까?


통계를 얻는 API 링크 목록은 다음과 같습니다.

페이스 북 : https://api.facebook.com/method/links.getStats?urls=%%URL%%&format=json
Reddit : http://buttons.reddit.com/button_info.json?url=%%URL% %
링크드 인 : http://www.linkedin.com/countserv/count/share?url=%%URL%%&format=json
디그 : http://widgets.digg.com/buttons/count?url=%%URL %%
맛있는 : http://feeds.delicious.com/v2/json/urlinfo/data?url=%%URL%%
StumbleUpon : http://www.stumbleupon.com/services/1.01/badge.getinfo?url = %% URL %%
Pinterest : http://widgets.pinterest.com/v1/urls/count.json?source=6&url=%%URL%%

편집 : Twitter 엔드 포인트가 사용되지 않으므로 제거되었습니다.

편집 : Facebook REST API는 더 이상 사용되지 않습니다


업데이트-'15 년 4 월 :

Like 버튼에서 사용 가능한 개수를 얻으려면 다음과 같이 객체 engagement필드를 사용해야합니다 og_object.

https://graph.facebook.com/v2.2/?id=http://www.MY-LINK.com&fields=og_object{engagement}&access_token=<access_token>

결과:

{
  "og_object": {
    "engagement": {
      "count": 93, 
      "social_sentence": "93 people like this."
    }, 
    "id": "801998203216179"
  }, 
  "id": "http://techcrunch.com/2015/04/06/they-should-have-announced-at-420/"
}

Graph API를 사용하면 가능합니다.

http://graph.facebook.com/?id=YOUR_URL

같은 :

http://graph.facebook.com/?id=http://www.google.com

돌아올 것이다 :

{
   "id": "http://www.google.com",
   "shares": 1163912
}

업데이트 : 위는 공유를 얻는 방법에 대한 답변 입니다. 이 숫자는 Like 버튼 에 표시되는 숫자 같지 않습니다. 해당 숫자는 다음의 합이므로

  • 이 URL의 좋아요 수
  • 이 URL의 공유 수 (Facebook으로의 링크 복사 / 붙여 넣기 포함)
  • 이 URL에 대한 Facebook 스토리의 좋아요 및 댓글 수
  • 이 URL을 첨부 파일로 포함하는받은 편지함 메시지 수입니다.

따라서 fql끝점 ( link_stat테이블)을 통해 Graph API를 사용하여 Like Button 번호를 얻을 수 있습니다 .

https://graph.facebook.com/fql?q=SELECT url, normalized_url, share_count, like_count, comment_count, total_count,commentsbox_count, comments_fbid, click_count FROM link_stat WHERE url='http://www.google.com'

total_count 좋아요 버튼에 표시되는 숫자입니다.


그래프 API를 사용해서는 안됩니다. 어느 쪽이든 전화하면 :

또는

둘 다 돌아옵니다 :

{
  "id": "http://www.apple.com",
  "shares": 1146997
}

그러나 표시된 숫자는 다음의 합입니다 .

  • 이 URL의 좋아요 수
  • 이 URL의 공유 수 (Facebook으로의 링크 복사 / 붙여 넣기 포함)
  • 이 URL에 대한 Facebook의 스토리에 대한 좋아요 및 댓글 수
  • 이 URL을 첨부 파일로 포함하는받은 편지함 메시지 수

따라서 FQL을 사용해야합니다.
이 답변보기 : 기사에서 페이스 북 좋아요, 공유, 댓글 수를 가져 오는 방법


2016 년 8 월 7 일 이후에도 다음과 같이 전화를 걸 수 있습니다.

http://graph.facebook.com/?id=https://www.apple.com/

but the response format is going to be different: it won't be

{
  "id": "http://www.apple.com",
  "shares": 1146997
}

but instead it will be

{
   "og_object": {
      "id": "388265801869",
      "description": "Get a first look at iPhone 7, Apple Watch Series 2, and the new AirPods \u2014 the future of wireless headphones. Visit the site to learn more.",
      "title": "Apple",
      "type": "website",
      "updated_time": "2016-09-20T08:21:03+0000"
   },
   "share": {
      "comment_count": 1,
      "share_count": 1094227
   },
   "id": "https://www.apple.com"
}

So you will have to process the response like this:

reponse_variable.share.share_count

What I found useful and I found on one link above is this FQL query where you ask for likes, total, share and click count of one link by looking at the link_stat table

https://graph.facebook.com/fql?q=SELECT%20like_count,%20total_count,%20share_count,%20click_count,%20comment_count%20FROM%20link_stat%20WHERE%20url%20=%20%22http://google.com%22

That will output something like this:

{
    data: [
        {
             like_count: 3440162,
             total_count: 13226503,
             share_count: 7732740,
             click_count: 265614,
             comment_count: 2053601
         }
    ]
}

Check out this gist. It has snippets for how to get the sharing count for the following services:

  • Facebook
  • Twitter
  • Google plus
  • Pinterest
  • LinkedIn
  • StumbledUpon

The facebook like button does two things that the API does not do. This might create confusion when you compare the two.

  1. If the URL you use in your like button has a redirect the button will actually show the count of the redirect URL versus the count of the URL you are using.

  2. If the page has a og:url property the like button will show the likes of that url instead of the url in the browser.

Hope this helps someone


Simply type in https://graph.facebook.com/?fields=share&id=https://www.example.com and replace example with your url or page you are looking for.

Example of Google: https://graph.facebook.com/?fields=share&id=https://www.google.com


when i used FQL I found the problem (but it is still problem) the documentation says that the number shown is the sum of:

  • number of likes of this URL
  • number of shares of this URL (this includes copy/pasting a link back to Facebook)
  • number of likes and comments on stories on Facebook about this URL
  • number of inbox messages containing this URL as an attachment.

but on my website the shown number is sum of these 4 counts + number of shares (again)


Using FQL you could do that:

http://graph.facebook.com/fql?q=SELECT url, total_count FROM link_stat WHERE url='PASTE_YOUR_URL_HERE'

There is a ruby gem for it - SocialShares

Currently it supports following social networks:

  • facebook
  • twitter
  • google plus
  • reddit
  • linkedin
  • pinterest
  • stumbleupon
  • vkontakte
  • mail.ru
  • odnoklassniki

Usage:

:000 > url = 'http://www.apple.com/'
  => "http://www.apple.com/"
:000 > SocialShares.facebook url
  => 394927
:000 > SocialShares.google url
  => 28289
:000 > SocialShares.twitter url
  => 1164675
:000 > SocialShares.all url
  => {:vkontakte=>44, :facebook=>399027, :google=>28346, :twitter=>1836, :mail_ru=>37, :odnoklassniki=>1, :reddit=>2361, :linkedin=>nil, :pinterest=>21011, :stumbleupon=>43035}
:000 > SocialShares.selected url, %w(facebook google linkedin)
  => {:facebook=>394927, :google=>28289, :linkedin=>nil}
:000 > SocialShares.total url, %w(facebook google)
  => 423216
:000 > SocialShares.has_any? url, %w(twitter linkedin)
  => true

You can use the https://graph.facebook.com/v3.0/{Place_your_Page_ID here}/feed?fields=id,shares,share_count&access_token={Place_your_access_token_here} to get the shares count.

참고URL : https://stackoverflow.com/questions/5699270/how-to-get-share-counts-using-graph-api

반응형