Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicCkPythonChilkat2-PythonRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcelGo

MFC Web API Examples

Primary Categories

ABN AMRO
AWS Secrets Manager
AWS Translate
Activix CRM
Adyen
Alibaba Cloud OSS
Amazon Cognito
Amazon DynamoDB
Amazon MWS
Amazon Pay
Amazon Rekognition
Amazon Voice ID
Aruba Fatturazione
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Backblaze S3
Bitfinex v2 REST
Bluzone
BrickLink
CallRail
CardConnect
Cerved
ClickBank
Clickatell
Cloudfare
Constant Contact
DocuSign
Duo Auth MFA
ETrade
Ecwid
Egypt ITIDA
Etsy
Facebook
Faire
Frame.io
GeoOp
GetHarvest
Global Payments
Google People
Google Search Console
Hungary NAV Invoicing
IBM Text to Speech
Ibanity
IntakeQ
Jira
Lightspeed
MYOB
Magento
Mailgun
Mastercard

MedTunnel
MercadoLibre
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Microsoft Teams
Moody's
Okta OAuth/OIDC
OneLogin OIDC
OneNote
PRODA
PayPal
Paynow.pl
Peoplevox
Populi
QuickBooks
Rabobank
Refinitiv
Royal Mail OBA
SCiS Schools Catalogue
SII Chile
SMSAPI
SOAP finkok.com
SendGrid
Shippo
Shopify
Shopware
Shopware 6
SimpleTexting
Square
Stripe
SugarCRM
TicketBAI
Trello
Twilio
Twitter
UniPin
VoiceBase
Vonage
Walmart
Walmart v3
Wasabi
WhatsApp
WiX
WooCommerce
WordPress
Xero
Yahoo Mail
Yousign
Zoom
_Miscellaneous_
eBay
effectconnect
hacienda.go.cr

 

 

 

(MFC) Facebook User Feed (Read Posts)

Demonstrates how to read the feed of posts (including status updates) and links published by this person, or by others on this person's profile. This introductory example gets the first few posts.

Chilkat C/C++ Library Downloads

MS Visual C/C++ Libs

See Also: Using MFC CString in Chilkat

#include <CkOAuth2.h>
#include <CkRest.h>
#include <CkJsonObject.h>
#include <CkDateTime.h>
#include <CkDtObj.h>

void ChilkatSample(void)
    {
    CkString strOut;

    // This example requires the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    // This example assumes a previously obtained an access token
    CkOAuth2 oauth2;
    oauth2.put_AccessToken("FACEBOOK-ACCESS-TOKEN");

    CkRest rest;

    // Connect to Facebook and send the following GET request:
    bool success = rest.Connect("graph.facebook.com",443,true,true);
    if (success != true) {
        strOut.append(rest.lastErrorText());
        strOut.append("\r\n");
        SetDlgItemText(IDC_EDIT1,strOut.getUnicode());
        return;
    }

    // Provide the authentication credentials (i.e. the access key)
    rest.SetAuthOAuth2(oauth2);

    // We could limit the number of posts.  The default limit is 25.
    rest.AddQueryParam("limit","5");

    const char *responseJson = rest.fullRequestNoBody("GET","/v2.7/me/feed");
    if (rest.get_LastMethodSuccess() != true) {
        strOut.append(rest.lastErrorText());
        strOut.append("\r\n");
        SetDlgItemText(IDC_EDIT1,strOut.getUnicode());
        return;
    }

    CkJsonObject json;
    json.put_EmitCompact(false);
    json.Load(responseJson);

    // Show the JSON in human-readable format.
    strOut.append(json.emit());
    strOut.append("\r\n");

    // A sample JSON response is shown below.  
    // This is the code to parse the JSON response.

    CkDateTime dtime;
    bool bLocalTime = true;

    CkDtObj *dt = 0;
    int i = 0;
    int numItems = json.SizeOfArray("data");
    while (i < numItems) {
        json.put_I(i);
        strOut.append("--- ");
        strOut.appendInt(i);
        strOut.append("\r\n");
        const char *message = json.stringOf("data[i].message");
        if (json.get_LastMethodSuccess() == true) {
            strOut.append("message: ");
            strOut.append(message);
            strOut.append("\r\n");
        }

        const char *story = json.stringOf("data[i].story");
        if (json.get_LastMethodSuccess() == true) {
            strOut.append("story: ");
            strOut.append(story);
            strOut.append("\r\n");
        }

        strOut.append("id: ");
        strOut.append(json.stringOf("data[i].id"));
        strOut.append("\r\n");

        // We can load the created_time into a CkDateTime...
        dtime.SetFromTimestamp(json.stringOf("data[i].created_time"));
        dt = dtime.GetDtObj(bLocalTime);
        strOut.appendInt(dt->get_Month());
        strOut.append("/");
        strOut.appendInt(dt->get_Day());
        strOut.append("/");
        strOut.appendInt(dt->get_Year());
        strOut.append("  ");
        strOut.appendInt(dt->get_Hour());
        strOut.append(":");
        strOut.appendInt(dt->get_Minute());
        strOut.append("\r\n");
        delete dt;
        i = i + 1;
    }

    // Finally, there are two paging URLs at the very bottom.  Those can be accessed as shown:
    const char *prevUrl = json.stringOf("paging.previous");
    strOut.append("URL for previous page: ");
    strOut.append(prevUrl);
    strOut.append("\r\n");

    const char *nextUrl = json.stringOf("paging.next");
    strOut.append("URL for next page: ");
    strOut.append(nextUrl);
    strOut.append("\r\n");

    // -------------------------------------------------------------------
    // This is a sample JSON response..
    // { 
    //   "data": [
    //     { 
    //       "message": "This is the first post.",
    //       "created_time": "2016-09-28T14:36:45+0000",
    //       "id": "12345678901234567_12345678900000001"
    //     },
    //     { 
    //       "message": "This is the 2nd post.",
    //       "created_time": "2016-09-27T03:26:12+0000",
    //       "id": "12345678901234567_12345678900000002"
    //     },
    //     { 
    //       "story": "John Doe shared Mary's post.",
    //       "created_time": "2016-09-26T15:45:10+0000",
    //       "id": "12345678901234567_12345678900000003"
    //     },
    //     { 
    //       "message": "https:\/\/www.somewebsite.org\/?ID=8158",
    //       "created_time": "2016-09-26T02:29:20+0000",
    //       "id": "12345678901234567_12345678900000004"
    //     },
    //     { 
    //       "message": "http:\/\/blog.somebody.com\/post\/123",
    //       "created_time": "2016-09-26T02:02:56+0000",
    //       "id": "12345678901234567_12345678900000005"
    //     },
    //     { 
    //       "story": "John Doe shared Bill's photo.",
    //       "created_time": "2016-09-25T15:32:09+0000",
    //       "id": "12345678901234567_12345678900000006"
    //     },
    //     { 
    //       "message": "Check this out...",
    //       "story": "John Doe shared NPR Music's video.",
    //       "created_time": "2016-09-25T14:54:52+0000",
    //       "id": "12345678901234567_12345678900000007"
    //     },
    //     { 
    //       "message": "Yet another post...",
    //       "created_time": "2016-09-24T17:21:30+0000",
    //       "id": "12345678901234567_12345678900000008"
    //     },
    //     { 
    //       "message": "http:\/\/www.somewhere.com\/blahblahblah\/",
    //       "created_time": "2016-09-23T22:20:29+0000",
    //       "id": "12345678901234567_12345678900000009"
    //     },
    //     { 
    //       "message": "At Lincoln marsh ...",
    //       "story": "John Doe added 2 new photos.",
    //       "created_time": "2016-09-19T02:00:43+0000",
    //       "id": "12345678901234567_12345678900000010"
    //     },
    //     { 
    //       "message": "I would've went for a swim had it not been for the sign",
    //       "created_time": "2016-09-19T01:59:47+0000",
    //       "id": "12345678901234567_12345678900000011"
    //     },
    //     { 
    //       "story": "John Doe shared Steve's video.",
    //       "created_time": "2016-09-17T22:00:02+0000",
    //       "id": "12345678901234567_12345678900000012"
    //     },
    //     { 
    //       "message": "Another sample message...",
    //       "story": "John Doe shared XYZ's post.",
    //       "created_time": "2016-09-17T14:13:16+0000",
    //       "id": "12345678901234567_12345678900000013"
    //     },
    //     { 
    //       "message": "Hello World!",
    //       "created_time": "2016-09-16T23:17:13+0000",
    //       "id": "12345678901234567_12345678900000014"
    //     },
    //     { 
    //       "message": "https:\/\/www.youtube.com\/watch?v=xyz",
    //       "created_time": "2016-09-15T04:13:02+0000",
    //       "id": "12345678901234567_12345678900000015"
    //     },
    //     { 
    //       "story": "John Doe shared Emily's photo.",
    //       "created_time": "2016-09-14T16:37:10+0000",
    //       "id": "12345678901234567_12345678900000016"
    //     },
    //     { 
    //       "story": "John Doe shared Vincent's photo.",
    //       "created_time": "2016-09-14T14:03:42+0000",
    //       "id": "12345678901234567_12345678900000017"
    //     },
    //     { 
    //       "message": "https:\/\/www.chilkatsoft.com\/",
    //       "created_time": "2016-09-14T02:29:37+0000",
    //       "id": "12345678901234567_12345678900000018"
    //     },
    //     { 
    //       "message": "So cool!  Marcus jamming with this 16 year old kid...",
    //       "created_time": "2016-09-13T17:04:53+0000",
    //       "id": "12345678901234567_12345678900000019"
    //     },
    //     { 
    //       "message": "Wow!",
    //       "story": "John Doe shared Somebody's post.",
    //       "created_time": "2016-09-13T14:11:18+0000",
    //       "id": "12345678901234567_12345678900000020"
    //     }
    //   ],
    //   "paging": { 
    //     "previous": "https:\/\/graph.facebook.com\/v2.7\/12345678901234567\/feed?since=1475073405&limit=25&__paging_token=enc_abcT9x9GFabcTxvnyXZC0xnHZCrH2h4yjNZCZAUabcZAI9TyZBibwat6wCYiSFTxR4nSDZAkzaN8vIaEPmqrabc1QTIbGac&__previous=1",
    //     "next": "https:\/\/graph.facebook.com\/v2.7\/12345678901234567\/feed?limit=25&until=1473426350&__paging_token=enc_AdDFWabcYtV5ob6lFO8LZAMhm7LKCxntawqqabcZALyC8WZB8Th2lON7HGuJRabzW6Ivfm93LORIw9NNBuHpob7abcjh"
    //   }
    // }
    // 


    SetDlgItemText(IDC_EDIT1,strOut.getUnicode());

    }

 

© 2000-2022 Chilkat Software, Inc. All Rights Reserved.