Hi all,

Currently am developing a wordpress blog to download free resouces.

I need a pure PHP script that allow useres to download files after liking my facebook page/follow my twitter page.

Thanks in advance...

Dani AI

Generated

Short summary and a couple of fixes to try. pointed to a script that uses the Facebook client events, and noted the download does not appear when a user already liked the page. Two important things to know today: Facebook forbids incentivizing likes (do not gate downloads behind a like) — see the Facebook Platform Policy (https://developers.facebook.com/policy/) — and many simple scripts only react to the like event and never check the current like state.

If you want reliable behavior without breaking policy: require the user to authenticate with Facebook (Facebook Login), then check the user's like state and decide what to show. The common bug you saw happens because the code listens only for the edge.create event (fires when a user clicks Like while on the page). To detect users who already liked the page you must query the Graph API after login. Quick client-side pattern:

FB.getLoginStatus(function(response) {
  if (response.status === 'connected') {
    FB.api('/me/likes/PAGE_ID', function(res) {
      if (res && res.data && res.data.length) {
        // unlock download (issue a one-time token from server)
      } else {
        // show Like button or prompt
      }
    });
  } else {
    // prompt Facebook Login
  }
});

Notes and practical tips: the Graph call requires the appropriate permission and app review, so plan for server-side token checks. For Twitter you must use OAuth and endpoints like friendships/show or friendships/lookup to verify following; that also requires user auth and obeys rate limits. Never serve direct file URLs — generate time-limited tokens or stream files through a PHP script that validates the token before sending the file.

Troubleshooting checklist for : ensure the JS SDK is initialized with your appId, use FB.getLoginStatus, call /me/likes/PAGE_ID to detect existing likes, do not rely only on edge.create, and protect the download URL server-side.

Recommended Answers

All 2 Replies

Thanks pritaeas for the link. But, when user already liked the page, download option not woring... :(

Let me tweak it.. :) really thanks once again for the link man.... :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.