Facebook obtains JSON data with OAuth validation

Source: Internet
Author: User
Tags oauth

First download the Facebook related dynamic library, download the file: Facebook.dll

To obtain the authorization token method:

  Private stringSettoken (stringGetToken)//Here is your short token, get a two month long token by token {stringShortlivedtoken =GetToken; varClient =Newfacebookclient (); IDictionary<string,Object>result; Try{result= client. Get ("/oauth/access_token",New{Grant_type="Fb_exchange_token", client_id="your ID", Client_secret="your secret.", Fb_exchange_token=Shortlivedtoken})  asidictionary<string,Object>; }            Catch(Exception ex) {Throw NewException (ex.            Message); }            stringtoken = result["Access_token"] as string; returntoken; }

Get the JSON string method:

  Public stringGETDATAFROMFB (stringAccess_token) {            if(!string. IsNullOrEmpty (Access_token)) {Try                {                    Objectpage =NULL; varClient =Newfacebookclient (Access_token); Page= client. Get ("https://graph.facebook.com/v2.0/content name/posts?limit=10&access_token="+Access_token); returnpage.                ToString (); }                Catch(Exception ex) {Throwex; }            }            Else            {                return "token cannot be found"; }        }

Facebook obtains JSON data with OAuth validation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.