Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] Uploadowanie postów na facebookową stronę
w9xp
post
Post #1





Grupa: Zarejestrowani
Postów: 5
Pomógł: 0
Dołączył: 12.06.2020

Ostrzeżenie: (0%)
-----


Czy ktoś ma jakiś tutorial dot. uploadowania przez PHP postów na moją, facebookową stronę firmową? Wiem, że odpowiada za to FB SDK, ale ktoś coś może więcej w temacie powiedzieć?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
w9xp
post
Post #2





Grupa: Zarejestrowani
Postów: 5
Pomógł: 0
Dołączył: 12.06.2020

Ostrzeżenie: (0%)
-----


Main.php

  1. <?php
  2. require "fbsdk/src/Facebook/autoload.php";
  3. $fb = new Facebook\Facebook([
  4. 'app_id' => '283257213082944',
  5. 'app_secret' => 'TUTAJWPISALEMAPPSECRET',
  6. 'default_graph_version' => 'v2.5',
  7. ]);
  8. ?>


Fb.php

  1. <?php
  2. require "main.php";
  3.  
  4. if (isset($_SESSION['token'])) {
  5. try {
  6.  
  7. $res = $fb->get('/me/accounts', $_SESSION['token']);
  8. $res = $res->getDecodedBody();
  9.  
  10. foreach($res['data'] as $page){
  11. echo $page['id'] . " - " . $page['name'] . "<br>";
  12.  
  13. }
  14.  
  15. ?>
  16.  
  17. <form method = "post" action = "page.php">
  18. <input type = "text" name = "pageid" placeholder = "Page ID">
  19. <input type = "text" name = "message" placeholder="Message">
  20. <input type = "submit">
  21. </form>
  22.  
  23. <?php
  24.  
  25. } catch( Facebook\Exceptions\FacebookSDKException $e ) {
  26. echo $e->getMessage();
  27. }
  28. }
  29. else{
  30. $helper = $fb->getRedirectLoginHelper();
  31. $permissions = ['email', 'user_posts', 'manage_pages', 'publish_actions', 'publish_pages'];
  32. $callback = 'http://packetcode.com/apps/srivathsan/pagepost/app.php';
  33. $loginUrl = $helper->getLoginUrl($callback, $permissions);
  34. echo '<a href="' . $loginUrl . '">Log in with Facebook!</a>';
  35. }
  36. ?>
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 15.10.2025 - 07:07