I currently have a client who came to me asking me how to build a system for him where he can give varying levels of discounts to events based on the number of people who get referred via a unique affiliate link/cookie.

The key stumbling block for this project isn't necessarily managing a code, but rather logging how many people share from the initial share and track any and all referrals from there. Essentially the discounts are all tiered based on signup counts so I'm not dealing with a flat commission per signup.

In case this is relevant, as my client is running on a Windows machine, MS SQL is the current database in place, and as such my PHP code will likely be piping the data back to that system rather than MySQL which again is my primary forte.

As this is my first time dabbling with the Facebook API, I wanted to know if there are any programs on the market already which do this, and also whether this can be coded easily using PHP (which is my primary area of expertise).

Bottom line however is that I want to know whether I can track the shares across Facebook and have that data sent back to the server. This is all purely for integration in Facebook, not a traditional web affiliate program.

Any insights are greatly appreciated.

Member Avatar

So you're saying you want to see the number of people who shared a specific link via Facebook ? You would need to obtain the Link ID somehow, then use this -> https://developers.facebook.com/docs/reference/api/link/

But, there doesn't seem to be any way to even see the number of shares, just likes.

Edit :

Should give you the amount of shares for any provided $link :)


$link = "http://www.daniweb.com/";
$graph = "http://graph.facebook.com/" . $link;
$graphText = file_get_contents($graph);

if (preg_match("/\"shares\":(.*),/", $graphText)) 
    $checkLikes = preg_match("/\"shares\":(.*),/", $graphText, $f);
    $checkLikes = $f[1];
else if (preg_match("/\"shares\":(.*)}/", $graphText)) 
    $checkLikes = preg_match("/\"shares\":(.*)}/", $graphText, $f);
    $checkLikes = $f[1];
    $checkLikes = 'fail';
echo $checkLikes;

Be a part of the DaniWeb community

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